mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
Add sourcelink support (#1574)
* add sourcelink support * Update sourcelink (2.0.2 -> 2.1.0) * Add parameter to enable source linking * tidy up the arguments with an extension method allowing an argument to be conditionally appended * Add an explicit "test sourcelink" build task and remove the MSBuild one, so we can get some build script output without needing the whole build to be in verbose logging * run sourcelink test against the NuGet packages
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
||||
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
|
||||
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
|
||||
<DebugType>embedded</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -32,4 +33,10 @@
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SourceLink.Create.GitHub" Version="2.1.0" PrivateAssets="All" />
|
||||
<DotNetCliToolReference Include="dotnet-sourcelink-git" Version="2.1.0" />
|
||||
<DotNetCliToolReference Include="dotnet-sourcelink" Version="2.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
||||
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
|
||||
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
|
||||
<DebugType>embedded</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -32,4 +33,10 @@
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SourceLink.Create.GitHub" Version="2.1.0" PrivateAssets="All" />
|
||||
<DotNetCliToolReference Include="dotnet-sourcelink-git" Version="2.1.0" />
|
||||
<DotNetCliToolReference Include="dotnet-sourcelink" Version="2.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -2,11 +2,11 @@ image: Visual Studio 2017
|
||||
|
||||
init:
|
||||
- git config --global core.autocrlf input
|
||||
|
||||
|
||||
build_script:
|
||||
- dotnet --info
|
||||
- ps: .\build.ps1
|
||||
|
||||
- ps: .\build.ps1 -LinkSources
|
||||
|
||||
test: off
|
||||
|
||||
artifacts:
|
||||
|
||||
@@ -24,6 +24,7 @@ Param(
|
||||
[string]$Target = "Default",
|
||||
[ValidateSet("Release", "Debug")]
|
||||
[string]$Configuration = "Release",
|
||||
[switch]$LinkSources,
|
||||
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
|
||||
[string]$Verbosity = "Verbose",
|
||||
[switch]$WhatIf,
|
||||
@@ -83,7 +84,7 @@ if($FoundDotNetCliVersion -ne $DotNetVersion) {
|
||||
###########################################################################
|
||||
|
||||
# Make sure nuget.exe exists.
|
||||
$NugetPath = Join-Path $ToolPath "nuget.exe"
|
||||
$NugetPath = Join-Path $ToolPath "nuget.exe"
|
||||
if (!(Test-Path $NugetPath)) {
|
||||
Write-Host "Downloading NuGet.exe..."
|
||||
(New-Object System.Net.WebClient).DownloadFile($NugetUrl, $NugetPath);
|
||||
@@ -97,6 +98,7 @@ if (!(Test-Path $NugetPath)) {
|
||||
$Arguments = @{
|
||||
target=$Target;
|
||||
configuration=$Configuration;
|
||||
linkSources=$LinkSources;
|
||||
verbosity=$Verbosity;
|
||||
dryrun=$WhatIf;
|
||||
}.GetEnumerator() | %{"--{0}=`"{1}`"" -f $_.key, $_.value };
|
||||
|
||||
4
build.sh
4
build.sh
@@ -5,7 +5,7 @@ if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
||||
ulimit -n 1024
|
||||
echo "new limit: `ulimit -n`"
|
||||
fi
|
||||
|
||||
|
||||
cd build
|
||||
dotnet restore
|
||||
dotnet run
|
||||
dotnet run -- --linkSources=true
|
||||
@@ -6,6 +6,7 @@ public class Context : FrostingContext
|
||||
{
|
||||
public string Target { get; set; }
|
||||
public string Configuration { get; set; }
|
||||
public bool LinkSources { get; set; }
|
||||
public BuildVersion Version { get; set; }
|
||||
|
||||
public DirectoryPath Artifacts { get; set; }
|
||||
|
||||
@@ -11,6 +11,7 @@ public class Lifetime : FrostingLifetime<Context>
|
||||
{
|
||||
context.Target = context.Argument<string>("target", "Default");
|
||||
context.Configuration = context.Argument<string>("configuration", "Release");
|
||||
context.LinkSources = context.Argument("linkSources", false);
|
||||
|
||||
context.Artifacts = "./packaging/";
|
||||
|
||||
@@ -58,12 +59,13 @@ public class Lifetime : FrostingLifetime<Context>
|
||||
context.Version.Prefix = context.Argument<string>("version", context.Version.Prefix);
|
||||
context.Version.Suffix = context.Argument<string>("suffix", context.Version.Suffix);
|
||||
|
||||
context.Information("Version: {0}", context.Version.Prefix);
|
||||
context.Information("Version: {0}", context.Version.Prefix);
|
||||
context.Information("Version suffix: {0}", context.Version.Suffix);
|
||||
context.Information("Configuration: {0}", context.Configuration);
|
||||
context.Information("Target: {0}", context.Target);
|
||||
context.Information("AppVeyor: {0}", context.AppVeyor);
|
||||
context.Information("TravisCI: {0}", context.TravisCI);
|
||||
context.Information("Configuration: {0}", context.Configuration);
|
||||
context.Information("LinkSources: {0}", context.LinkSources);
|
||||
context.Information("Target: {0}", context.Target);
|
||||
context.Information("AppVeyor: {0}", context.AppVeyor);
|
||||
context.Information("TravisCI: {0}", context.TravisCI);
|
||||
}
|
||||
|
||||
private static bool IsBuildTagged(BuildSystem buildSystem)
|
||||
|
||||
@@ -11,7 +11,9 @@ public class Build : FrostingTask<Context>
|
||||
context.DotNetCoreBuild("./Octokit.sln", new DotNetCoreBuildSettings
|
||||
{
|
||||
Configuration = context.Configuration,
|
||||
ArgumentCustomization = args => args.Append("/p:Version={0}", context.Version.GetSemanticVersion())
|
||||
ArgumentCustomization = args => args
|
||||
.Append("/p:Version={0}", context.Version.GetSemanticVersion())
|
||||
.AppendIfTrue(context.LinkSources, "/p:SourceLinkCreate=true")
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using Cake.Frosting;
|
||||
|
||||
[Dependency(typeof(Package))]
|
||||
[Dependency(typeof(TestSourceLink))]
|
||||
public sealed class Default : FrostingTask<Context>
|
||||
{
|
||||
}
|
||||
36
build/Tasks/TestSourceLink.cs
Normal file
36
build/Tasks/TestSourceLink.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using Cake.Common;
|
||||
using Cake.Common.Diagnostics;
|
||||
using Cake.Common.IO;
|
||||
using Cake.Core;
|
||||
using Cake.Core.IO;
|
||||
using Cake.Frosting;
|
||||
|
||||
[Dependency(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;
|
||||
}
|
||||
}
|
||||
10
build/Utilities/CakeExtensions.cs
Normal file
10
build/Utilities/CakeExtensions.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Cake.Core;
|
||||
using Cake.Core.IO;
|
||||
|
||||
public static class CakeExtensions
|
||||
{
|
||||
public static ProcessArgumentBuilder AppendIfTrue(this ProcessArgumentBuilder builder, bool condition, string format, params object[] args)
|
||||
{
|
||||
return condition ? builder.Append(format, args) : builder;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user