[maint] Removes the old implementation of sourcelink and uses the newer one present in the .net SDK (#2666)

* reoves the old implemetnation of sourcelink and uses the newer one  present in the .net SDK

* cleans up appveyor

* updates proj with sourcelink props

* adds deterministic build check as well.

* Update docs/debugging-source.md

Co-authored-by: Keegan Campbell <me@kfcampbell.com>

---------

Co-authored-by: Keegan Campbell <me@kfcampbell.com>
This commit is contained in:
Nick Floyd
2023-02-07 11:14:49 -06:00
committed by GitHub
parent e3e27bbe04
commit 00b89daa23
15 changed files with 30 additions and 87 deletions

View File

@@ -2,12 +2,6 @@
"version": 1, "version": 1,
"isRoot": true, "isRoot": true,
"tools": { "tools": {
"sourcelink": {
"version": "3.1.1",
"commands": [
"sourcelink"
]
},
"dotnet-format": { "dotnet-format": {
"version": "5.1.250801", "version": "5.1.250801",
"commands": [ "commands": [

View File

@@ -28,5 +28,5 @@ jobs:
with: with:
dotnet-version: 6.0.* dotnet-version: 6.0.*
- name: Build with dotnet - name: Build with dotnet
run: ./build.sh --linksources=true --verbosity=verbose run: ./build.sh --verbosity=verbose
shell: bash shell: bash

View File

@@ -22,7 +22,7 @@ jobs:
with: with:
dotnet-version: 6.0.* dotnet-version: 6.0.*
- name: Build with dotnet - name: Build with dotnet
run: ./build.sh --linksources=true --verbosity=verbose run: ./build.sh --verbosity=verbose
shell: bash shell: bash
- name: Publish to NuGet - name: Publish to NuGet

View File

@@ -72,11 +72,11 @@ To install dependencies and run the CAKE build script use the following wrapper
- Windows (Powershell) - Windows (Powershell)
`.\build.ps1 -Target <target> -Configuration Release -LinkSources [Additional Parameters]` `.\build.ps1 -Target <target> -Configuration Release [Additional Parameters]`
- Linux/OSX (bash) - Linux/OSX (bash)
`./build.sh --target=<target> --configuration==Release --linksources=true [Additional Parameters]` `./build.sh --target=<target> --configuration==Release [Additional Parameters]`
### Running Tests ### Running Tests

View File

@@ -22,6 +22,16 @@
<PropertyGroup> <PropertyGroup>
<NoWarn>$(NoWarn);1591;1701;1702;1705</NoWarn> <NoWarn>$(NoWarn);1591;1701;1702;1705</NoWarn>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
<PropertyGroup Label="Source Link">
<!-- Optional: Declare that the Repository URL can be published to NuSpec -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<!-- Optional: Embed source files that are not tracked by the source control manager to the PDB -->
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<!-- Optional: Include PDB in the built .nupkg -->
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -22,6 +22,16 @@
<PropertyGroup> <PropertyGroup>
<DefineConstants>$(DefineConstants);SIMPLE_JSON_INTERNAL;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_READONLY_COLLECTIONS;SIMPLE_JSON_TYPEINFO</DefineConstants> <DefineConstants>$(DefineConstants);SIMPLE_JSON_INTERNAL;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_READONLY_COLLECTIONS;SIMPLE_JSON_TYPEINFO</DefineConstants>
<NoWarn>$(NoWarn);1591;1701;1702;1705</NoWarn> <NoWarn>$(NoWarn);1591;1701;1702;1705</NoWarn>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
<PropertyGroup Label="Source Link">
<!-- Optional: Declare that the Repository URL can be published to NuSpec -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<!-- Optional: Embed source files that are not tracked by the source control manager to the PDB -->
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<!-- Optional: Include PDB in the built .nupkg -->
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,7 +1,6 @@
# Octokit - GitHub API Client Library for .NET # Octokit - GitHub API Client Library for .NET
![Build status](https://github.com/octokit/octokit.net/workflows/CI%20Build/badge.svg) ![Build status](https://github.com/octokit/octokit.net/workflows/CI%20Build/badge.svg)
[![Build status](https://ci.appveyor.com/api/projects/status/cego2g42yw26th26/branch/main?svg=true)](https://ci.appveyor.com/project/github-windows/octokit-net/branch/main)
[![codecov](https://codecov.io/gh/octokit/octokit.net/branch/main/graph/badge.svg)](https://codecov.io/gh/octokit/octokit.net) [![codecov](https://codecov.io/gh/octokit/octokit.net/branch/main/graph/badge.svg)](https://codecov.io/gh/octokit/octokit.net)
[![Join the chat at https://gitter.im/octokit/octokit.net](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/octokit/octokit.net?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Join the chat at https://gitter.im/octokit/octokit.net](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/octokit/octokit.net?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![NuGet](https://img.shields.io/nuget/v/Octokit.svg)](https://www.nuget.org/packages/Octokit) [![NuGet](https://img.shields.io/nuget/v/Octokit.svg)](https://www.nuget.org/packages/Octokit)
@@ -42,13 +41,6 @@ There is also an IObservable based GitHub API client library for .NET using Reac
dotnet add package Octokit.Reactive dotnet add package Octokit.Reactive
``` ```
### Beta packages ###
Unstable NuGet packages that track the `main` branch of this repository are available at
[https://ci.appveyor.com/nuget/octokit-net](https://ci.appveyor.com/nuget/octokit-net)
In Xamarin Studio you can find this option under the project's context menu: **Add | Add Packages...***.
## Documentation ## Documentation
Documentation is available at http://octokitnet.readthedocs.io/en/latest/. Documentation is available at http://octokitnet.readthedocs.io/en/latest/.

View File

@@ -24,7 +24,6 @@ Param(
[string]$Target = "Default", [string]$Target = "Default",
[ValidateSet("Release", "Debug")] [ValidateSet("Release", "Debug")]
[string]$Configuration = "Release", [string]$Configuration = "Release",
[switch]$LinkSources,
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
[string]$Verbosity = "Normal", [string]$Verbosity = "Normal",
[switch]$WhatIf, [switch]$WhatIf,
@@ -98,7 +97,6 @@ if (!(Test-Path $NugetPath)) {
$Arguments = @{ $Arguments = @{
target=$Target; target=$Target;
configuration=$Configuration; configuration=$Configuration;
linkSources=$LinkSources;
verbosity=$Verbosity; verbosity=$Verbosity;
dryrun=$WhatIf; dryrun=$WhatIf;
}.GetEnumerator() | %{"--{0}=`"{1}`"" -f $_.key, $_.value }; }.GetEnumerator() | %{"--{0}=`"{1}`"" -f $_.key, $_.value };

View File

@@ -9,7 +9,6 @@ public class Context : FrostingContext
{ {
public string Target { get; set; } public string Target { get; set; }
public new string Configuration { get; set; } public new string Configuration { get; set; }
public bool LinkSources { get; set; }
public bool FormatCode { get; set; } public bool FormatCode { get; set; }
public BuildVersion Version { get; set; } public BuildVersion Version { get; set; }
@@ -17,11 +16,8 @@ public class Context : FrostingContext
public bool IsLocalBuild { get; set; } public bool IsLocalBuild { get; set; }
public bool IsPullRequest { get; set; } public bool IsPullRequest { get; set; }
public bool IsOriginalRepo { get; set; } public bool IsOriginalRepo { get; set; }
public bool IsTagged { get; set; }
public bool IsMainBranch { get; set; } public bool IsMainBranch { get; set; }
public bool ForcePublish { get; set; } public bool ForcePublish { get; set; }
public bool AppVeyor { get; set; }
public bool GitHubActions { get; set; } public bool GitHubActions { get; set; }
public Project[] Projects { get; set; } public Project[] Projects { get; set; }

View File

@@ -12,7 +12,6 @@ public class Lifetime : FrostingLifetime<Context>
{ {
context.Target = context.Argument("target", "Default"); context.Target = context.Argument("target", "Default");
context.Configuration = context.Argument("configuration", "Release"); context.Configuration = context.Argument("configuration", "Release");
context.LinkSources = context.Argument("linkSources", false);
context.FormatCode = context.Argument("formatCode", false); context.FormatCode = context.Argument("formatCode", false);
context.Artifacts = "./packaging/"; context.Artifacts = "./packaging/";
@@ -22,16 +21,8 @@ public class Lifetime : FrostingLifetime<Context>
context.IsLocalBuild = buildSystem.IsLocalBuild; context.IsLocalBuild = buildSystem.IsLocalBuild;
context.GitHubActions = buildSystem.GitHubActions.IsRunningOnGitHubActions; context.GitHubActions = buildSystem.GitHubActions.IsRunningOnGitHubActions;
context.AppVeyor = buildSystem.AppVeyor.IsRunningOnAppVeyor;
context.IsTagged = IsBuildTagged(buildSystem);
if (context.AppVeyor) if (context.GitHubActions)
{
context.IsPullRequest = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest;
context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals("octokit/octokit.net", buildSystem.AppVeyor.Environment.Repository.Name);
context.IsMainBranch = StringComparer.OrdinalIgnoreCase.Equals("main", buildSystem.AppVeyor.Environment.Repository.Branch);
}
else if (context.GitHubActions)
{ {
context.IsPullRequest = buildSystem.GitHubActions.Environment.PullRequest.IsPullRequest; context.IsPullRequest = buildSystem.GitHubActions.Environment.PullRequest.IsPullRequest;
context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals("octokit/octokit.net", buildSystem.GitHubActions.Environment.Workflow.Repository); context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals("octokit/octokit.net", buildSystem.GitHubActions.Environment.Workflow.Repository);
@@ -62,18 +53,10 @@ public class Lifetime : FrostingLifetime<Context>
context.Information("Version: {0}", context.Version.Prefix); context.Information("Version: {0}", context.Version.Prefix);
context.Information("Version suffix: {0}", context.Version.Suffix); context.Information("Version suffix: {0}", context.Version.Suffix);
context.Information("Configuration: {0}", context.Configuration); context.Information("Configuration: {0}", context.Configuration);
context.Information("LinkSources: {0}", context.LinkSources);
context.Information("Target: {0}", context.Target); context.Information("Target: {0}", context.Target);
context.Information("AppVeyor: {0}", context.AppVeyor);
context.Information("GitHub Actions: {0}", context.GitHubActions); context.Information("GitHub Actions: {0}", context.GitHubActions);
} }
private static bool IsBuildTagged(BuildSystem buildSystem)
{
return buildSystem.AppVeyor.Environment.Repository.Tag.IsTag
&& !string.IsNullOrWhiteSpace(buildSystem.AppVeyor.Environment.Repository.Tag.Name);
}
private static string GetEnvironmentValueOrArgument(Context context, string environmentVariable, string argumentName) private static string GetEnvironmentValueOrArgument(Context context, string environmentVariable, string argumentName)
{ {
var arg = context.EnvironmentVariable(environmentVariable); var arg = context.EnvironmentVariable(environmentVariable);

View File

@@ -13,8 +13,7 @@ public class Build : FrostingTask<Context>
{ {
Configuration = context.Configuration, Configuration = context.Configuration,
ArgumentCustomization = args => args ArgumentCustomization = args => args
.Append("/p:Version={0}", context.Version.GetSemanticVersion()) .Append("/p:Version={0}", context.Version.GetSemanticVersion()),
.Append("/p:SourceLinkCreate={0}", context.LinkSources.ToString().ToLower()),
}); });
} }
} }

View File

@@ -1,6 +1,5 @@
using Cake.Frosting; using Cake.Frosting;
[IsDependentOn(typeof(Package))]
[IsDependentOn(typeof(TestSourceLink))]
public sealed class Default : FrostingTask<Context> public sealed class Default : FrostingTask<Context>
{ {
} }

View File

@@ -1,36 +0,0 @@
using System;
using Cake.Common;
using Cake.Common.Diagnostics;
using Cake.Common.IO;
using Cake.Core;
using Cake.Core.IO;
using Cake.Frosting;
[IsDependentOn(typeof(Package))]
public class TestSourceLink : FrostingTask<Context>
{
public override void Run(Context context)
{
var nugetPackages = context.GetFiles($"./{context.Artifacts}/*.nupkg");
foreach (var nugetPackage in nugetPackages)
{
context.Information("Testing sourcelink info in {0}", context.Environment.WorkingDirectory.GetRelativePath(nugetPackage));
var exitCode = context.StartProcess("dotnet", new ProcessSettings
{
WorkingDirectory = "Octokit",
Arguments = $"sourcelink test {nugetPackage.FullPath}"
});
if (exitCode != 0)
{
throw new Exception("Sourcelink test failed!");
}
}
}
public override bool ShouldRun(Context context)
{
return context.LinkSources;
}
}

View File

@@ -22,11 +22,9 @@ with a specific type, and cache it in your local symbols cache.
![F11 step into symbol](https://cloud.githubusercontent.com/assets/359239/5389259/74600502-8149-11e4-94f7-10dc79a0573f.gif) ![F11 step into symbol](https://cloud.githubusercontent.com/assets/359239/5389259/74600502-8149-11e4-94f7-10dc79a0573f.gif)
You can then set subsequent breakpoints inside the source code, to return to You can then set subsequent breakpoints inside the source code, to return to
in the debugging session. in the debugging session.
### Acknowledgements ### Acknowledgements
Thanks to [Cameron Taggart](http://blog.ctaggart.com/) for building the Thanks to Cameron Taggart for the initial implementation and the .NET foundation for ongoing support of [SourceLink](https://github.com/dotnet/sourcelink) which we use to provide source debugging.
[SourceLink](https://github.com/ctaggart/SourceLink) framework which we use
to support this behaviour.

View File

@@ -26,7 +26,7 @@ Or can be run individually:
### Create NuGet Packages ### Create NuGet Packages
NuGet packages are automatically generated (and SourceLinked) by the CAKE build script. NuGet packages are automatically generated (and SourceLinked) by the csproj configration.
> `.\build.ps1` > `.\build.ps1`
The output .nupkg files will be located in the `packaging` directory. The output .nupkg files will be located in the `packaging` directory.