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

WIP Git Versioning #13

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

WIP Git Versioning #13

wants to merge 1 commit into from

Conversation

jthelin
Copy link
Owner

@jthelin jthelin commented May 23, 2016

  • Use GitVersion tool to stamp version numbers into assemblies.

@jthelin
Copy link
Owner Author

jthelin commented May 23, 2016

Travis CI build fails with error:

Project "/home/travis/build/jthelin/ServerHost/ServerHost.sln" (default target(s)):
    Target ValidateSolutionConfiguration:
        Building solution configuration "Debug|Any CPU".
    Target Build:
        Project "/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj" (default target(s)):
/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj:  warning : Target 'EnsureNuGetManifestMetadata', not found in the project
            Target PrepareForBuild:
                Configuration: Debug Platform: AnyCPU
                Created directory "bin/Debug/"
                Created directory "obj/Debug/"
            Target CopyFilesMarkedCopyLocal:
                Copying file from '/home/travis/build/jthelin/ServerHost/packages/log4net.2.0.3/lib/net40-full/log4net.dll' to '/home/travis/build/jthelin/ServerHost/ServerHost/bin/Debug/log4net.dll'
            Target GetBuildVersion:
/home/travis/build/jthelin/ServerHost/packages/Nerdbank.GitVersioning.1.4.30/build/NerdBank.GitVersioning.targets: error : Error executing task GetBuildVersion: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: git2-e0902fb
  at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods:git_libgit2_init ()
  at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject..ctor () <0x40beef30 + 0x0000b> in <filename unknown>:0 
  at LibGit2Sharp.Core.NativeMethods..cctor () <0x40beecf0 + 0x001af> in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject.Finalize () <0x40bf1650 + 0x00013> in <filename unknown>:0 

@jthelin jthelin self-assigned this May 23, 2016
@jthelin jthelin changed the title GitVersioning Git Versioning Oct 25, 2017
@jthelin
Copy link
Owner Author

jthelin commented Oct 25, 2017

Travis-CI build fails with:

"/home/travis/build/jthelin/ServerHost/ServerHost.sln" (default target) (1) ->
"/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj" (default target) (2) ->
(WriteVersionInfoToBuildLog target) ->
 MSBUILD : warning : WARN [10/25/17 17:45:35:44] Failed to check build server 'ContinuaCi': No access to the given key [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
 MSBUILD : warning : WARN [10/25/17 17:45:35:86] Failed to inherit Increment branch configuration, no branches found. [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
MSBUILD : warning : [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
MSBUILD : warning : Falling back to master branch config [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
 MSBUILD : warning : WARN [10/25/17 17:45:35:88] Could not determine assembly version: LibGit2Sharp.NotFoundException: Object not found - no match for id (e6b2f6199df514da7fe9b5d7554d221f4492b947) [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
MSBUILD : warning : at LibGit2Sharp.Core.Ensure.HandleError (System.Int32 result) [0x00057] in <ecba14039ea0427fac6be14e5af4f4d5>:0 [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
MSBUILD : warning : at LibGit2Sharp.Core.Ensure.ZeroResult (System.Int32 result) [0x00004] in <ecba14039ea0427fac6be14e5af4f4d5>:0 [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
MSBUILD : warning : at LibGit2Sharp.Core.Proxy.git_revwalk_next (LibGit2Sharp.Core.Handles.RevWalkerHandle walker) [0x00015] in <ecba14039ea0427fac6be14e5af4f4d5>:0 [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
MSBUILD : warning : at LibGit2Sharp.CommitLog+CommitEnumerator.MoveNext () [0x00000] in <ecba14039ea0427fac6be14e5af4f4d5>:0 [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
MSBUILD : warning : at System.Linq.Enumerable.TryGetFirst[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate, System.Boolean& found) [0x0004f] in <7c7d16af841f44d5a362340966c7fd69>:0 [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
MSBUILD : warning : at System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) [0x00000] in <7c7d16af841f44d5a362340966c7fd69>:0 [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
MSBUILD : warning : at GitVersion.VersionCalculation.FallbackBaseVersionStrategy+<GetVersions>d__0.MoveNext () [0x0004a] in <ecba14039ea0427fac6be14e5af4f4d5>:0 [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
MSBUILD : warning : at System.Linq.Enumerable+SelectManySingleSelectorIterator`2[TSource,TResult].MoveNext () [0x0006f] in <7c7d16af841f44d5a362340966c7fd69>:0 [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
MSBUILD : warning : at System.Linq.Enumerable+WhereSelectEnumerableIterator`2[TSource,TResult].ToList () [0x0003b] in <7c7d16af841f44d5a362340966c7fd69>:0 [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
MSBUILD : warning : at System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0001f] in <7c7d16af841f44d5a362340966c7fd69>:0 [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
MSBUILD : warning : at GitVersion.VersionCalculation.BaseVersionCalculator.GetBaseVersion (GitVersion.GitVersionContext context) [0x00057] in <ecba14039ea0427fac6be14e5af4f4d5>:0 [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
MSBUILD : warning : at GitVersion.VersionCalculation.NextVersionCalculator.FindVersion (GitVersion.GitVersionContext context) [0x0003f] in <ecba14039ea0427fac6be14e5af4f4d5>:0 [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
MSBUILD : warning : at GitVersion.GitVersionFinder.FindVersion (GitVersion.GitVersionContext context) [0x00060] in <ecba14039ea0427fac6be14e5af4f4d5>:0 [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
MSBUILD : warning : at GitVersion.ExecuteCore+<>c__DisplayClass6_0.<ExecuteInternal>b__0 (LibGit2Sharp.IRepository repo) [0x00014] in <ecba14039ea0427fac6be14e5af4f4d5>:0 [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
MSBUILD : warning : at GitVersion.GitPreparer.WithRepository[TResult] (System.Func`2[T,TResult] action) [0x0000c] in <ecba14039ea0427fac6be14e5af4f4d5>:0 [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
MSBUILD : warning : at GitVersion.ExecuteCore.ExecuteInternal (System.String targetBranch, System.String commitId, GitVersion.GitPreparer gitPreparer, GitVersion.IBuildServer buildServer, GitVersion.Config overrideConfig) [0x0002d] in <ecba14039ea0427fac6be14e5af4f4d5>:0 [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
MSBUILD : warning : at GitVersion.ExecuteCore.ExecuteGitVersion (System.String targetUrl, System.String dynamicRepositoryLocation, GitVersion.Authentication authentication, System.String targetBranch, System.Boolean noFetch, System.String workingDirectory, System.String commitId, GitVersion.Config overrideConfig) [0x000c7] in <ecba14039ea0427fac6be14e5af4f4d5>:0 [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]
MSBUILD : warning : at GitVersion.ExecuteCore.TryGetVersion (System.String directory, GitVersion.VersionVariables& versionVariables, System.Boolean noFetch, GitVersion.Authentication authentication) [0x00000] in <ecba14039ea0427fac6be14e5af4f4d5>:0 [/home/travis/build/jthelin/ServerHost/ServerHost/ServerHost.csproj]

@jthelin jthelin force-pushed the GitVersioning branch 2 times, most recently from 8688f47 to e40e6c2 Compare October 25, 2017 20:08
@jthelin jthelin force-pushed the GitVersioning branch 2 times, most recently from aa6ffd8 to 99491fe Compare November 3, 2017 08:52
@jthelin jthelin force-pushed the GitVersioning branch 3 times, most recently from 5fd6111 to 1d641ba Compare October 2, 2018 23:44
@jthelin jthelin changed the title Git Versioning WIP Git Versioning Nov 8, 2018
@jthelin jthelin force-pushed the GitVersioning branch 5 times, most recently from 0bf3f5d to 74ce89d Compare November 12, 2018 05:20
@jthelin jthelin force-pushed the GitVersioning branch 4 times, most recently from e8cfd87 to aef0901 Compare November 21, 2018 23:07
@jthelin
Copy link
Owner Author

jthelin commented Dec 4, 2018

Linux build still failing with error:

2018-12-04T18:02:22.6601166Z "/home/vsts/work/1/s/ServerHost.sln" (default target) (1) ->
2018-12-04T18:02:22.6601998Z "/home/vsts/work/1/s/ServerHost/ServerHost.csproj" (default target) (2) ->
2018-12-04T18:02:22.6602670Z (WriteVersionInfoToBuildLog target) -> 
2018-12-04T18:02:22.6604817Z   /home/vsts/.nuget/packages/gitversiontask/4.0.1-beta1-50/build/functionality/GitVersionBuild.targets(6,5):
 error MSB4175: The task factory "UtilPack.NuGet.MSBuild.NuGetTaskRunnerFactory" could not be loaded from the assembly "/home/vsts/.nuget/packages/utilpack.nuget.msbuild/2.9.1/build/net46/UtilPack.NuGet.MSBuild.dll".
 Could not load type of field 'UtilPack.NuGet.BoundRestoreCommandUser:_clientPolicyContext' (8) due to:
 Could not resolve type with token 0100006c from typeref (expected class 'NuGet.Packaging.Signing.ClientPolicyContext' in assembly 'NuGet.Packaging, Version=4.9.0.6, Culture=neutral, PublicKeyToken=31bf3856ad364e35')
 assembly:NuGet.Packaging, Version=4.9.0.6, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 type:NuGet.Packaging.Signing.ClientPolicyContext
 member:(null)
 [/home/vsts/work/1/s/ServerHost/ServerHost.csproj]

@jthelin
Copy link
Owner Author

jthelin commented Dec 4, 2018

I suspect the real culprit here is that GitVersionTask depends on NuGet package UtilPack.NuGet.MSBuild which looks like it does not support net45 directly, only net46 and netcoreapp1.1.

Not exactly sure why this works OK when building on Windows, though.

- Use GitVersion to stamp version numbers into assemblies.

https://github.com/GitTools/GitVersion

Use GitVersioning variables to set NuGet package version properties.

Use Mainline versioning policy in GitVersion v4.0+.

- Bump next version to 1.2.x for easier reference.

Only run `GitVersionTask` during Windows builds.

Failure more on Linux:
```
2018-12-04T18:02:22.6601166Z "/home/vsts/work/1/s/ServerHost.sln" (default target) (1) ->
2018-12-04T18:02:22.6601998Z "/home/vsts/work/1/s/ServerHost/ServerHost.csproj" (default target) (2) ->
2018-12-04T18:02:22.6602670Z (WriteVersionInfoToBuildLog target) ->
2018-12-04T18:02:22.6604817Z   /home/vsts/.nuget/packages/gitversiontask/4.0.1-beta1-50/build/functionality/GitVersionBuild.targets(6,5):
 error MSB4175: The task factory "UtilPack.NuGet.MSBuild.NuGetTaskRunnerFactory" could not be loaded
   from the assembly "/home/vsts/.nuget/packages/utilpack.nuget.msbuild/2.9.1/build/net46/UtilPack.NuGet.MSBuild.dll".
 Could not load type of field 'UtilPack.NuGet.BoundRestoreCommandUser:_clientPolicyContext' (8) due to:
 Could not resolve type with token 0100006c from typeref (expected class 'NuGet.Packaging.Signing.ClientPolicyContext' in assembly 'NuGet.Packaging, Version=4.9.0.6, Culture=neutral, PublicKeyToken=31bf3856ad364e35')
 assembly:NuGet.Packaging, Version=4.9.0.6, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 type:NuGet.Packaging.Signing.ClientPolicyContext
 member:(null)
 [/home/vsts/work/1/s/ServerHost/ServerHost.csproj]
```
@jthelin jthelin marked this pull request as draft June 1, 2020 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant