GitVersion: the combination of VS 2019 Version 16.5.0 Preview 2.0 and .NET Core 3.1.200-preview-014883 fails dotnet build
If you install VS 2019 Version 16.5.0 Preview 2.0 (Released 1/22/2020), dotnet build
fails with this error. Here’s a related StackOverflow question/answer on how to work around.
https://stackoverflow.com/a/59876257/1603663
I don’t know if this issue is a bug in .net core, or an update required in GitVersion
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: System.TypeInitializationException: The type initializer for 'GitVersion.MSBuildTask.TaskProxy' threw an exception. [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): 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. [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: File name: 'GitVersionTask.MsBuild, Version=5.1.3.0, Culture=neutral, PublicKeyToken=null' [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): 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. [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: File name: 'GitVersionTask.MsBuild, Version=5.1.3.0, Culture=neutral, PublicKeyToken=null' [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly assemblyContext, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext) [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext) [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: at System.Reflection.Assembly.Load(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext) [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName(AssemblyName assemblyName) [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: at GitVersion.MSBuildTask.LibGit2Sharp.GitLoaderContext.Load(AssemblyName assemblyName) in D:\a\1\s\src\GitVersionTask.MsBuild\LibGit2Sharp\GitLoaderContext.cs:line 30 [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingLoad(AssemblyName assemblyName) [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName) [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: at System.Reflection.RuntimeAssembly.GetType(QCallAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive, ObjectHandleOnStack assemblyLoadContext) [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: at System.Reflection.Assembly.GetType(String name, Boolean throwOnError) [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: at GitVersion.MSBuildTask.TaskProxy..cctor() in D:\a\1\s\src\GitVersionTask.MsBuild\TaskProxy.cs:line 22 [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: --- End of inner exception stack trace --- [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: at GitVersion.MSBuildTask.Tasks.WriteVersionInfoToBuildLog.Execute() in D:\a\1\s\src\GitVersionTask.MsBuild\Tasks\WriteVersionInfoToBuildLog.cs:line 5 [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [ProjectFile]
C:\Users\benb\.nuget\packages\gitversiontask\5.1.3\build\GitVersionTask.targets(10,9): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [ProjectFile]```
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 6
- Comments: 26 (15 by maintainers)
Commits related to this issue
- Work around for GitVersion: https://github.com/GitTools/GitVersion/issues/2063#issuecomment-600568003 — committed to SacredSkull/dotnet-tidal-usdk by SacredSkull 4 years ago
- Convert .cake to use DotNetCore* instead of MSBuild Update GitVersionTask to 5.3.7 because of issue with dotnet build https://github.com/GitTools/GitVersion/issues/2063 — committed to oelderinkX/FileCache by deleted user 4 years ago
Notes on what I’ve figured out so far. I don’t see a super clear path forward at the moment, will continue to look on Monday:
TaskProxy
has an explicit reference to the stub implementations of the tasks inGitVersionTask.MsBuild
TaskProxy
tries to load the assemblyGitVersionTask
in its privateGitLoaderContext
ALCGitVersionTask
depends onGitVersionTask.MsBuild
, and the typeGitVersion.MSBuildTask.GitVersionTasks
has explicit references back to it, so when it’s not available in the private ALC it fails with the original errorat
If you amend the private ALC to also load
GitVersionTask.MsBuild
, we get past that, but the immediately following linefails, because the
GetVersion
in the type parameter is in the task ALC, while theGetVersion
returned from reflection is in theGitLoaderContext
ALC, so they don’t match and you getIn the old MSBuild, there was no task ALC, only the default ALC. That meant that
GitVersionTask.MsBuild
is loaded in the default ALCGitVersionTask
assembly is loaded in the privateGitLoaderContext
ALCGitVersion.MSBuildTask.GitVersionTasks
,GitVersionTask.MsBuild
is not foundI noticed that as well. I’ll need to find a fix for this
I experience the same issue with the released 3.1.200 and GitVersionTask 5.2.4. All our CI builds fail now. Unfortunately, even a global.json with 3.1.101 does not help.
Can confirm that it’s fixed 👍
This is likely a result of MSBuild changes to improve task isolation (microsoft/msbuild#4916). However, it looks like GitVersion has its own GitLoaderContext, which should have insulated you from that change.
If you’re affected by this, can you try setting the environment variable
MSBUILDSINGLELOADCONTEXT=1
before your build and reporting whether that helps. If it does, it’s a lighter-weight workaround than downgrading to SDK 3.1.1xx.I’ve uninstalled 16.5 and installed 16.4.5 (for reference, you can get specific versions here). However, this didn’t help, as each build agent has its own copy of dotnet + SDK, therefore I had to remove
_tools/dotnet
folder of each agent manually. Afterwards all pipelines built successfully, even with GitVersionTask 5.2.4. I.e. the pressure is reduced 😅Hum that’s correct, thanks for pointing me this mistake!
@jmevel You seem to be using GitVersionTask 5.0.1, not 5.3.7, check your log.
Neither pinning to 3.1.101 with global.json nor a downgrade of GitVersionTask to 5.1.2 does help 😕
@barrett777 Thanks for the link to the workaround 😃