dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.23k stars 1.35k forks source link

Azure Cloud Service Worker Role "compile" assemblies copied from nuget package instead of "runtime" version #5335

Open alexeizalesski opened 4 years ago

alexeizalesski commented 4 years ago

I have azure cloud service project with worker role. I have nuget package referenced, here is what I see in project.assets.json of my worker project:

"Microsoft.Bcl.AsyncInterfaces/1.1.0": { "type": "package", "dependencies": { "System.Threading.Tasks.Extensions": "4.5.2" }, "frameworkAssemblies": [ "mscorlib" ], "compile": { "ref/net461/Microsoft.Bcl.AsyncInterfaces.dll": {} }, "runtime": { "lib/net461/Microsoft.Bcl.AsyncInterfaces.dll": {} } },

When I build worker project then DLL from "runtime" section is properly copied to output folder, but when I build cloud service project, then DLL from "compile" section is copied to obj and csx folder of cloud project, so cloud service package contains wrong DLL as well. As a result I receive exception when run project in azure cloud emulator or on real azure cloud service:

could not load file or assembly 'microsoft.bcl.asyncinterfaces, version=1.0.0.0, culture=neutral, publickeytoken=cc7b13ffcd2ddd51' or one of its dependencies. reference assemblies should not be loaded for execution

rainersigwald commented 4 years ago

I'm not sure whether this is a bug in NuGet handling transitive assets or in the cloud service SDK. Do you have a repro project you can share? That could help route.

alexeizalesski commented 4 years ago

Here is my sample solution

[AzureCloudService.Sample.zip] (https://github.com/microsoft/msbuild/files/4587988/AzureCloudService.Sample.zip)

If you start CloudService project you will see an exception.

And as I mentioned ealrier at AzureCloudService.Sample\WorkerRole.Sample\bin\Debug\ you may find proper runtime DLL, but here AzureCloudService.Sample\AzureCloudService.Sample\csx\Debug\roles\WorkerRole.Sample\approot\ you will find "referrence assembly" DLL which is not working.

extragen commented 4 years ago

@alexeizalesski have you found a solution?

extragen commented 4 years ago

found workaround here https://github.com/Azure/azure-sdk-for-net/issues/3699#issuecomment-612306965