Visual Studio 2017 15.8.6 MSBuild System.Collections.Immutable version mismatch
Steps to reproduce
Cannot build project after upgraded to Visual Studio 2017 15.8.6. Trying msbuild.exe and get this error
System.IO.FileLoadException: Could not load file or assembly 'System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
File name::“System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”
在 System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
在 System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters()
在 System.Reflection.RuntimeMethodInfo.GetParameters()
在 System.Diagnostics.StackTrace.ToString(TraceFormat traceFormat)
在 System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
在 System.Exception.GetStackTrace(Boolean needFileInfo)
在 System.Exception.ToString(Boolean needFileLineInfo, Boolean needMessage)
在 System.Exception.ToString()
在 Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary2 globalProperties, Dictionary2 restoreProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Boolean needToValidateProject, String schemaFile, Int32 cpuCount, Boolean enableNodeReuse, TextWriter preprocessWriter, Boolean detailedSummary, ISet1 warningsAsErrors, ISet1 warningsAsMessages, Boolean enableRestore, ProfilerLogger profilerLogger, Boolean enableProfiler)
在 Microsoft.Build.CommandLine.MSBuildApp.Execute(String commandLine)
Project file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
</Project>
Directory contents:
/
- Program.cs
Command line
msbuild ConsoleApp1.csproj /v:diag
Expected behavior
Actual behavior
Environment data
msbuild /version output:
15.7.180.61344
OS info:
Windows 10
If applicable, version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc):
dotnet --list-sdks
2.1.402 [C:\Program Files\dotnet\sdk]
====================== Current workaround is replacing "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\System.Collections.Immutable.dll" with an 1.2.1 version from "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Packages\Microsoft.Net.Compilers.2.4.0\tools\System.Collections.Immutable.dll"
Sadly, still cannot build project whith Visual Studio. Don't know why.
Projects build fine after downgraded Visual Studio to 15.7.6.
When previously reported, this is almost always a result of the machine having (incorrectly) had Microsoft.Build.* assemblies added to the GAC. Can you try running these commands from an administrator developer command prompt?
gacutil /u "MSBuild, Version=15.1.0.0"
gacutil /u "Microsoft.Build.Conversion.Core, Version=15.1.0.0"
gacutil /u "Microsoft.Build, Version=15.1.0.0"
gacutil /u "Microsoft.Build.Engine, Version=15.1.0.0"
gacutil /u "Microsoft.Build.Tasks.Core, Version=15.1.0.0"
gacutil /u "Microsoft.Build.Utilities.Core, Version=15.1.0.0"
gacutil /u "Microsoft.Build.Framework, Version=15.1.0.0"
issue resolved. Thanks!