question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.NET Core SDK 3.1.200 breaks build which is using GitVersionTask

See original GitHub issue

Using GitVersionTask 5.1.2 with CoreWCF builds successfully with .NET Core SDK 3.1.101, but when the SDK was updated by a recent VS update, it broke the build. I have also tried GitVersion 5.1.3 and the latest 5.2.3 with the same result. Reinstalling .NET Core SDK 3.1.101 (as VS updater removes it) and adding a global.json file to specify using that version of the SDK results in the build succeeding again. Here is the error message I get from the build:

 error MSB4018: The "WriteVersionInfoToBuildLog" task failed unexpectedly. [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018: System.TypeInitializationException: The type initializer for 'GitVersion.MSBuildTask.TaskProxy' threw an exception. [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:  ---> System.IO.FileNotFoundException: Could not load file or assembly 'GitVersionTask.MsBuild, Version=5.1.3.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018: File name: 'GitVersionTask.MsBuild, Version=5.1.3.0, Culture=neutral, PublicKeyToken=null' [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:  ---> System.IO.FileNotFoundException: Could not load file or assembly 'GitVersionTask.MsBuild, Version=5.1.3.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018: File name: 'GitVersionTask.MsBuild, Version=5.1.3.0, Culture=neutral, PublicKeyToken=null' [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:    at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly assemblyContext, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext) [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:    at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext) [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:    at System.Reflection.Assembly.Load(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext) [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:    at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName(AssemblyName assemblyName) [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:    at GitVersion.MSBuildTask.LibGit2Sharp.GitLoaderContext.Load(AssemblyName assemblyName) in D:\a\1\s\src\GitVersionTask.MsBuild\LibGit2Sharp\GitLoaderContext.cs:line 30 [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:    at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingLoad(AssemblyName assemblyName) [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:    at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName) [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:  [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:  [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:    at System.Reflection.RuntimeAssembly.GetType(QCallAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive, ObjectHandleOnStack assemblyLoadContext) [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:    at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:    at System.Reflection.Assembly.GetType(String name, Boolean throwOnError) [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:    at GitVersion.MSBuildTask.TaskProxy..cctor() in D:\a\1\s\src\GitVersionTask.MsBuild\TaskProxy.cs:line 22 [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:  [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:  [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:    --- End of inner exception stack trace --- [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:    at GitVersion.MSBuildTask.Tasks.WriteVersionInfoToBuildLog.Execute() in D:\a\1\s\src\GitVersionTask.MsBuild\Tasks\WriteVersionInfoToBuildLog.cs:line 5 [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]
 error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [C:\git\CoreWCF\src\CoreWCF.Primitives\src\CoreWCF.Primitives.csproj]

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
dasMullicommented, Apr 1, 2020

Can you try a dotnet build-server shutdown before the run with changed ENV var to make sure there are no leftover msbuild nodes?

1reaction
rainersigwaldcommented, Apr 6, 2020

@onyxmaster Thanks! This appears to have been fixed in Fody 6.0.4, probably by https://github.com/Fody/Fody/commit/7f4f425692b23fb5520312418d5642566ccc7577. I was able to get your repro working by forcing an updated ref:

diff --git a/Independent.csproj b/Independent.csproj
index c915944..294ba7b 100644
--- a/Independent.csproj
+++ b/Independent.csproj
@@ -5,5 +5,6 @@
 
   <ItemGroup>
     <PackageReference Include="ModuleInit.Fody" Version="2.1.0" PrivateAssets="all"/>
+    <PackageReference Include="Fody" Version="6.0.4" PrivateAssets="all"/>
   </ItemGroup>
 </Project>

FYI @simoncropp.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'Could not load file or assembly GitVersionTask.MsBuild' when ...
With the release of .NET Core SDK 3.1.200, GitVersionTask fails the VC platform build with messages like The "WriteVersionInfoToBuildLog" ...
Read more >
MSBuild breaking changes in .NET Core 2.1 - 3.1
Lists the breaking changes in MSBuild for .NET Core 2.1 ... NET Core SDK 3.1.400, only top-level package references are returned by the ......
Read more >
Azure DevOps .NET Core build and publish doesn't keep ...
I'm managing the application version number with the GitVersion task ( gittools.gitversion.gitversion-task.GitVersion@4 ) in the YAML build. The ...
Read more >
GitVersion changelog - Awesome .NET - LibHunt
2': a reference with that name already exists. Improvement. #1770 [Azure DevOps] Leave the original Build Number when no GitVersion variable in Build...
Read more >
GitVersion.Tool 5.12.0
Derives SemVer information from a repository following GitFlow or GitHubFlow. This is the .NET Core Global Tool allowing usage of GitVersion from command ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found