Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sourcelink support #1574

Merged
merged 6 commits into from
Apr 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Octokit.Reactive/Octokit.Reactive.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<DebugType>embedded</DebugType>
</PropertyGroup>

<ItemGroup>
Expand All @@ -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>
7 changes: 7 additions & 0 deletions Octokit/Octokit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<DebugType>embedded</DebugType>
</PropertyGroup>

<ItemGroup>
Expand All @@ -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>
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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 };
Expand Down
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions build/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
12 changes: 7 additions & 5 deletions build/Lifetime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public override void Setup(Context context)
{
context.Target = context.Argument<string>("target", "Default");
context.Configuration = context.Argument<string>("configuration", "Release");
context.LinkSources = context.Argument("linkSources", false);

context.Artifacts = "./packaging/";

Expand Down Expand Up @@ -58,12 +59,13 @@ public override void Setup(Context 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)
Expand Down
4 changes: 3 additions & 1 deletion build/Tasks/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ public override void Run(Context 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")
});
}
}
2 changes: 1 addition & 1 deletion build/Tasks/Default.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Cake.Frosting;

[Dependency(typeof(Package))]
[Dependency(typeof(TestSourceLink))]
public sealed class Default : FrostingTask<Context>
{
}
36 changes: 36 additions & 0 deletions build/Tasks/TestSourceLink.cs
Original file line number Diff line number Diff line change
@@ -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 changes: 10 additions & 0 deletions build/Utilities/CakeExtensions.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}