I have a solution with an azure cloud project and a worker role project (+ some auxiliary projects). When I debug the worker locally, I get this exception:
Could not load file or assembly 'System.Runtime.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"System.Runtime.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
FusionLog:
=== Pre-bind state information ===
LOG: DisplayName = System.Runtime.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/Azure/roles/[worker project]/approot
LOG: Initial PrivatePath = C:\Azure\roles\[worker project]\approot
Calling assembly : Microsoft.Extensions.Configuration, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Azure\roles\[worker project]\approot\[worker assembly].dll.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 4.0.0.0 redirected to 4.1.1.0.
LOG: Post-policy reference: System.Runtime.Extensions, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: Attempting download of new URL file:///C:/Azure/roles/[worker project]/approot/System.Runtime.Extensions.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
What I see in build output:
2> Task "Message"
2> CopyLocalDependencies=[solution]\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll
2> Task "Message"
2> CopyLocalDependencies=C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Facades\System.Runtime.Extensions.dll
...
2> Task "Message"
2> WorkerFiles=[solution]\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll -> System.Runtime.Extensions.dll
2> Task "Message"
2> WorkerFiles=C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Facades\System.Runtime.Extensions.dll -> System.Runtime.Extensions.dll
...
2> Copying file from "[solution]\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll" to "[solution]\[azure project]\obj\Debug\[worker project]\System.Runtime.Extensions.dll".
2> Copying file from "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Facades\System.Runtime.Extensions.dll" to "[solution]\[azure project]\obj\Debug\[worker project]\System.Runtime.Extensions.dll".
Why does MSBuild copy GAC's assembly to a local folder? How to change this behaviour? I do not have a direct reference to the GAC's System.Runtime.Extensions. Or how to change the order of copying assemblies?
What I tried:
- Add the property in the worker project DoNotCopyLocalIfInGac = true
- Add a direct reference to the nuget package System.Runtime.Extensions
UPD Found similar problems