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

Exclude LibGit2Sharp from ILRepack in NuGet.CommandLine #890

Merged
merged 7 commits into from
Jul 9, 2016
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
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ os:
- linux
- osx
before_install: # We need to download nuget.exe due to: https://github.com/travis-ci/travis-ci/issues/5932
- git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags
- mkdir -p .nuget
- wget -O .nuget/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
- mono .nuget/nuget.exe
install:
- mono .nuget/nuget.exe restore src/GitVersion.sln -Verbosity detailed
- mono .nuget/nuget.exe install NUnit.Runners -Version 3.2.1 -OutputDirectory ./src/packages
script:
- xbuild ./src/GitVersion.sln /property:Configuration="Debug" /verbosity:detailed
- mono ./build/NuGetCommandLineBuild/tools/GitVersion.exe -l console -output buildserver -updateAssemblyInfo
- xbuild ./src/GitVersion.sln /property:Configuration="Debug" /verbosity:detailed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

demystifying-evr

- mono ./src/packages/NUnit.ConsoleRunner.3.2.1/tools/nunit3-console.exe ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionCore.Tests/bin/Debug/GitVersionCore.Tests.dll ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionExe.Tests/bin/Debug/GitVersionExe.Tests.dll --where "cat != NoMono" --noresult

Expand All @@ -23,4 +26,4 @@ script:
#
# To run a clean build with Mono, executing all tests, do:
# xbuild ./src/GitVersion.sln /t:Clean /verbosity:quiet && xbuild ./src/GitVersion.sln /property:Configuration="Debug" /verbosity:quiet && mono ./src/packages/NUnit.ConsoleRunner.3.2.1/tools/nunit3-console.exe ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionCore.Tests/bin/Debug/GitVersionCore.Tests.dll ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionExe.Tests/bin/Debug/GitVersionExe.Tests.dll --noresult --where "cat != NoMono" --noresult
#
#
3 changes: 2 additions & 1 deletion src/GitVersionCore.Tests/ExecuteCoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ public void DynamicRepositoriesShouldNotErrorWithFailedToFindGitDirectory()
string RepositoryScope(ExecuteCore executeCore = null, Action<EmptyRepositoryFixture, VersionVariables> fixtureAction = null)
{
// Make sure GitVersion doesn't trigger build server mode when we are running the tests
Environment.SetEnvironmentVariable("APPVEYOR", null);
Environment.SetEnvironmentVariable(AppVeyor.EnvironmentVariableName, null);
Environment.SetEnvironmentVariable(TravisCI.EnvironmentVariableName, null);
var infoBuilder = new StringBuilder();
Action<string> infoLogger = s =>
{
Expand Down
6 changes: 4 additions & 2 deletions src/GitVersionCore/BuildServers/AppVeyor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

public class AppVeyor : BuildServerBase
{
public override bool CanApplyToCurrentContext()
public const string EnvironmentVariableName = "APPVEYOR";

public override bool CanApplyToCurrentContext()
{
return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("APPVEYOR"));
return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(EnvironmentVariableName));
}

public override string GenerateSetVersionMessage(VersionVariables variables)
Expand Down
3 changes: 2 additions & 1 deletion src/GitVersionCore/BuildServers/BuildServerList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public static class BuildServerList
new MyGet(),
new Jenkins(),
new GitLabCi(),
new VsoAgent()
new VsoAgent(),
new TravisCI(),
};

public static IEnumerable<IBuildServer> GetApplicableBuildServers()
Expand Down
6 changes: 4 additions & 2 deletions src/GitVersionCore/BuildServers/TeamCity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

public class TeamCity : BuildServerBase
{
public override bool CanApplyToCurrentContext()
public const string EnvironmentVariableName = "TEAMCITY_VERSION";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor issue: Wouldn't a static readonly variable fit better? For cases where this value is used in another assembly and the core assembly is replaced (But most probably this won't happen anyway :)


public override bool CanApplyToCurrentContext()
{
return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("TEAMCITY_VERSION"));
return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(EnvironmentVariableName));
}

public override string GetCurrentBranch(bool usingDynamicRepos)
Expand Down
32 changes: 32 additions & 0 deletions src/GitVersionCore/BuildServers/TravisCI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
namespace GitVersion
{
public class TravisCI : BuildServerBase
{
public const string EnvironmentVariableName = "TRAVIS";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto regarding const vs static readonly


public override bool CanApplyToCurrentContext ()
{
return "true".Equals(Environment.GetEnvironmentVariable(EnvironmentVariableName)) && "true".Equals(Environment.GetEnvironmentVariable("CI"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this case sensitive by design?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have Fody.Caseless running which makes everything automatically case insensitive.

}

public override string GenerateSetVersionMessage(VersionVariables variables)
{
return variables.FullSemVer;
}

public override string[] GenerateSetParameterMessage(string name, string value)
{
return new[]
{
string.Format("GitVersion_{0}={1}", name, value)
};
}

public override bool PreventFetch ()
{
return true;
}
}
}

1 change: 1 addition & 0 deletions src/GitVersionCore/GitVersionCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
<Compile Include="SemanticVersion.cs" />
<Compile Include="SemanticVersionBuildMetaData.cs" />
<Compile Include="SemanticVersionPreReleaseTag.cs" />
<Compile Include="BuildServers\TravisCI.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="FodyWeavers.xml">
Expand Down
2 changes: 1 addition & 1 deletion src/GitVersionCore/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Caseless.Fody" version="1.4.1" targetFramework="net40" developmentDependency="true" />
<package id="Caseless.Fody" version="1.4.2" targetFramework="net40" developmentDependency="true" />
<package id="Fody" version="1.29.4" targetFramework="net40" developmentDependency="true" />
<package id="GitTools.Core" version="1.1.0-beta0001" targetFramework="net40" />
<package id="JetBrainsAnnotations.Fody" version="1.0.4.0" targetFramework="net4" developmentDependency="true" />
Expand Down
6 changes: 4 additions & 2 deletions src/GitVersionExe.Tests/GitVersionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Text;
using GitTools;
using GitVersion;

public static class GitVersionHelper
{
Expand Down Expand Up @@ -36,8 +37,9 @@ static ExecutionResults ExecuteIn(ArgumentBuilder arguments)
var environmentalVariables =
new[]
{
new KeyValuePair<string, string>("TEAMCITY_VERSION", arguments.IsTeamCity ? "8.0.0" : null),
new KeyValuePair<string, string>("APPVEYOR", null)
new KeyValuePair<string, string>(TeamCity.EnvironmentVariableName, arguments.IsTeamCity ? "8.0.0" : null),
new KeyValuePair<string, string>(AppVeyor.EnvironmentVariableName, null),
new KeyValuePair<string, string>(TravisCI.EnvironmentVariableName, null),
};

var exitCode = -1;
Expand Down
32 changes: 21 additions & 11 deletions src/GitVersionExe/GitVersionExe.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,34 @@
]]></Code>
</Task>
</UsingTask>
<Target Name="AfterBuild" DependsOnTargets="Clean" Condition="$(NCrunch)=='' And '$(OS)' != 'Unix'">
<Target Name="AfterBuild" DependsOnTargets="Clean" Condition="$(NCrunch)==''">
<MakeDir Directories="$(TargetDir)ILMergeTemp\" />
<PropertyGroup>
<Runtime Condition="'$(OS)'=='Unix'">mono</Runtime>
</PropertyGroup>
<!-- Copy target file so that our temporary file gets the correct permissions -->
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(TargetDir)ILMergeTemp\" />
<Exec Command="$(Runtime) &quot;$(SolutionDir)packages\ILRepack.2.0.10\tools\ILRepack.exe&quot; /allowDup /keyfile:&quot;$(SolutionDir)key.snk&quot; /out:&quot;$(TargetDir)ILMergeTemp\$(TargetFileName)&quot; &quot;$(TargetPath)&quot; &quot;$(TargetDir)GitVersionCore.dll&quot; &quot;$(TargetDir)GitTools.Core.dll&quot; &quot;$(TargetDir)LibGit2Sharp.dll&quot; &quot;$(TargetDir)YamlDotNet.dll&quot; /target:exe /targetplatform:&quot;v4,$(FrameworkPathOverride)&quot; /ndebug /internalize " />
<ItemGroup>
<TempFiles Include="$(TargetDir)ILMergeTemp\*.*" />
<NativeBinaries Include="$(TargetDir)lib\**\*.*" />
<WindowsBinaries Include="$(TargetDir)lib\**\*.dll" />
<LibGit2SharpFiles Include="$(TargetDir)LibGit2Sharp.*" Exclude="$(TargetDir)LibGit2Sharp.xml" />
</ItemGroup>

<!-- Repack without LibGit2Sharp for NugetCommandLineBuild -->
<Exec Command="$(Runtime) &quot;$(SolutionDir)packages\ILRepack.2.0.10\tools\ILRepack.exe&quot; /allowDup /keyfile:&quot;$(SolutionDir)key.snk&quot; /out:&quot;$(TargetDir)ILMergeTemp\$(TargetFileName)&quot; &quot;$(TargetPath)&quot; &quot;$(TargetDir)GitVersionCore.dll&quot; &quot;$(TargetDir)GitTools.Core.dll&quot; &quot;$(TargetDir)YamlDotNet.dll&quot; /target:exe /targetplatform:&quot;v4,$(FrameworkPathOverride)&quot; /ndebug /internalize " />
<!-- NugetCommandLineBuild -->
<MakeDir Directories="$(BuildDir)NuGetCommandLineBuild" />
<Copy SourceFiles="@(NativeBinaries)" DestinationFiles="@(NativeBinaries->'$(BuildDir)NuGetCommandLineBuild\tools\lib\%(RecursiveDir)%(Filename)%(Extension)')" />
<Copy SourceFiles="@(LibGit2SharpFiles)" DestinationFolder="$(BuildDir)NuGetCommandLineBuild\tools" />
<Copy SourceFiles="$(OutputPath)GitVersion.pdb" DestinationFolder="$(BuildDir)NuGetCommandLineBuild\tools" Condition="Exists('$(OutputPath)GitVersion.pdb')" />
<Copy SourceFiles="$(OutputPath)GitVersion.exe.mdb" DestinationFolder="$(BuildDir)NuGetCommandLineBuild\tools" Condition="Exists('$(OutputPath)GitVersion.exe.mdb')" />
<Copy SourceFiles="$(OutputPath)ILMergeTemp\GitVersion.exe" DestinationFolder="$(BuildDir)NuGetCommandLineBuild\tools" />
<Copy SourceFiles="$(ProjectDir)NugetAssets\GitVersion.CommandLine.nuspec" DestinationFolder="$(BuildDir)NuGetCommandLineBuild" />
<PepitaPackage.CreatePackageTask NuGetBuildDirectory="$(BuildDir)NuGetCommandLineBuild" MetadataAssembly="$(OutputPath)ILMergeTemp\GitVersion.exe" Version="$(GitVersion_NuGetVersion)" />

<!-- Repack with LibGit2Sharp for NugetCommandLineBuild -->
<Exec Command="$(Runtime) &quot;$(SolutionDir)packages\ILRepack.2.0.10\tools\ILRepack.exe&quot; /allowDup /keyfile:&quot;$(SolutionDir)key.snk&quot; /out:&quot;$(TargetDir)ILMergeTemp\$(TargetFileName)&quot; &quot;$(TargetPath)&quot; &quot;$(TargetDir)GitVersionCore.dll&quot; &quot;$(TargetDir)GitTools.Core.dll&quot; &quot;$(TargetDir)LibGit2Sharp.dll&quot; &quot;$(TargetDir)YamlDotNet.dll&quot; /target:exe /targetplatform:&quot;v4,$(FrameworkPathOverride)&quot; /ndebug /internalize " />
<!-- NugetExeBuild -->
<MakeDir Directories="$(BuildDir)NuGetExeBuild" />
<Copy SourceFiles="@(NativeBinaries)" DestinationFiles="@(NativeBinaries->'$(BuildDir)NuGetExeBuild\tools\lib\%(RecursiveDir)%(Filename)%(Extension)')" />
Expand All @@ -158,14 +173,7 @@
<Copy SourceFiles="$(ProjectDir)NugetAssets\chocolateyUninstall.ps1" DestinationFolder="$(BuildDir)NuGetExeBuild\tools" />
<Copy SourceFiles="$(ProjectDir)NugetAssets\GitVersion.Portable.nuspec" DestinationFolder="$(BuildDir)NuGetExeBuild" />
<PepitaPackage.CreatePackageTask NuGetBuildDirectory="$(BuildDir)NuGetExeBuild" MetadataAssembly="$(OutputPath)ILMergeTemp\GitVersion.exe" Version="$(GitVersion_NuGetVersion)" />
<!-- NugetCommandLineBuild -->
<MakeDir Directories="$(BuildDir)NuGetCommandLineBuild" />
<Copy SourceFiles="@(NativeBinaries)" DestinationFiles="@(NativeBinaries->'$(BuildDir)NuGetCommandLineBuild\tools\lib\%(RecursiveDir)%(Filename)%(Extension)')" />
<Copy SourceFiles="$(OutputPath)GitVersion.pdb" DestinationFolder="$(BuildDir)NuGetCommandLineBuild\tools" Condition="Exists('$(OutputPath)GitVersion.pdb')" />
<Copy SourceFiles="$(OutputPath)GitVersion.exe.mdb" DestinationFolder="$(BuildDir)NuGetCommandLineBuild\tools" Condition="Exists('$(OutputPath)GitVersion.exe.mdb')" />
<Copy SourceFiles="$(OutputPath)ILMergeTemp\GitVersion.exe" DestinationFolder="$(BuildDir)NuGetCommandLineBuild\tools" />
<Copy SourceFiles="$(ProjectDir)NugetAssets\GitVersion.CommandLine.nuspec" DestinationFolder="$(BuildDir)NuGetCommandLineBuild" />
<PepitaPackage.CreatePackageTask NuGetBuildDirectory="$(BuildDir)NuGetCommandLineBuild" MetadataAssembly="$(OutputPath)ILMergeTemp\GitVersion.exe" Version="$(GitVersion_NuGetVersion)" />

<!-- TfsBuildTask -->
<Copy SourceFiles="@(NativeBinaries)" DestinationFiles="@(NativeBinaries->'$(BuildDir)GitVersionTfsTaskBuild\GitVersionTask\lib\%(RecursiveDir)%(Filename)%(Extension)')" />
<Copy SourceFiles="$(OutputPath)GitVersion.pdb" DestinationFolder="$(BuildDir)GitVersionTfsTaskBuild" Condition="Exists('$(OutputPath)GitVersion.pdb')" />
Expand All @@ -175,13 +183,14 @@
<Copy SourceFiles="$(SolutionDir)GitVersionTfsTask\builds.png" DestinationFolder="$(BuildDir)GitVersionTfsTaskBuild\img" />
<Copy SourceFiles="$(SolutionDir)GitVersionTfsTask\build-task.png" DestinationFolder="$(BuildDir)GitVersionTfsTaskBuild\img" />
<Copy SourceFiles="$(OutputPath)ILMergeTemp\GitVersion.exe" DestinationFolder="$(BuildDir)GitVersionTfsTaskBuild\GitVersionTask" />
<Copy SourceFiles="$(OutputPath)GitVersion.pdb" DestinationFolder="$(BuildDir)GitVersionTfsTaskBuild\GitVersionTask" />
<Copy SourceFiles="$(OutputPath)GitVersion.pdb" DestinationFolder="$(BuildDir)GitVersionTfsTaskBuild\GitVersionTask" Condition="Exists('$(OutputPath)GitVersion.pdb')" />
<Copy SourceFiles="$(SolutionDir)GitVersionTfsTask\icon.png" DestinationFolder="$(BuildDir)GitVersionTfsTaskBuild\GitVersionTask" />
<Copy SourceFiles="$(SolutionDir)GitVersionTfsTask\task.json" DestinationFolder="$(BuildDir)GitVersionTfsTaskBuild\GitVersionTask" />
<Copy SourceFiles="$(SolutionDir)GitVersionTfsTask\GitVersion.ps1" DestinationFolder="$(BuildDir)GitVersionTfsTaskBuild\GitVersionTask" />
<ReplaceFileText InputFilename="$(BuildDir)GitVersionTfsTaskBuild\manifest.json" OutputFilename="$(BuildDir)GitVersionTfsTaskBuild\manifest.json" MatchExpression="\$version\$" ReplacementText="$(GitVersion_SemVer)" Condition="'$(GitVersion_SemVer)' != ''" />
<Exec Command="powershell -ExecutionPolicy RemoteSigned -NoProfile &quot;$(SolutionDir)GitVersionTfsTask\Update-GitVersionTfsTaskVersion.ps1 $(BuildDir)GitVersionTfsTaskBuild\GitVersionTask\task.json $(GitVersion_Major) $(GitVersion_Minor) $(GitVersion_Patch)&quot;" WorkingDirectory="$(BuildDir)" Condition="'$(GitVersion_SemVer)' != ''" />
<Exec Command="powershell -ExecutionPolicy RemoteSigned -NoProfile &quot;$(SolutionDir)GitVersionTfsTask\Create-Vsix.ps1 $(BuildDir)GitVersionTfsTaskBuild&quot;" Condition="'$(GitVersion_SemVer)' != ''" />

<!-- Gem -->
<MakeDir Directories="$(BuildDir)GemBuild" />
<!-- Gem can only treat files it knows about, so it throws an error for .so and .dylib files when building on Windows -->
Expand All @@ -205,6 +214,7 @@
</PropertyGroup>
<ReplaceFileText InputFilename="$(BuildDir)GemBuild\gitversion.gemspec" OutputFilename="$(BuildDir)GemBuild\gitversion.gemspec" MatchExpression="\$version\$" ReplacementText="$(GemVersion)" Condition="'$(GitVersion_SemVer)' != ''" />
<Exec Command="gem build gitversion.gemspec" ContinueOnError="True" WorkingDirectory="$(BuildDir)GemBuild" Condition="'$(GitVersion_SemVer)' != ''" />

<!-- Cleanup -->
<RemoveDir Directories="$(TargetDir)ILMergeTemp\" />
</Target>
Expand Down
2 changes: 1 addition & 1 deletion src/GitVersionExe/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Caseless.Fody" version="1.4.1" targetFramework="net40" developmentDependency="true" />
<package id="Caseless.Fody" version="1.4.2" targetFramework="net40" developmentDependency="true" />
<package id="Fody" version="1.29.4" targetFramework="net40" developmentDependency="true" />
<package id="GitTools.Core" version="1.1.0-beta0001" targetFramework="net40" />
<package id="ILRepack" version="2.0.10" targetFramework="net40" />
Expand Down
2 changes: 1 addition & 1 deletion src/GitVersionTask/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Caseless.Fody" version="1.4.1" targetFramework="net40" developmentDependency="true" />
<package id="Caseless.Fody" version="1.4.2" targetFramework="net40" developmentDependency="true" />
<package id="Fody" version="1.29.4" targetFramework="net40" developmentDependency="true" />
<package id="GitTools.Core" version="1.1.0-beta0001" targetFramework="net40" />
<package id="ILRepack" version="2.0.10" targetFramework="net40" />
Expand Down