dotnet / orleans

Cloud Native application framework for .NET
https://docs.microsoft.com/dotnet/orleans
MIT License
10.07k stars 2.03k forks source link

Build-time code generation version 2.0.4 breaks docker builds #4877

Closed mikkoairaksinen closed 5 years ago

mikkoairaksinen commented 6 years ago

When upgrading the Microsoft.Orleans.OrleansCodeGenerator.Build package to version 2.0.4, docker builds with the microsoft/dotnet:2.1.401-sdk base image start to fail with the error message below. Building on the host machine with the exact same commands as in the Dockerfile does not produce the error, nor does running the project in an IDE.

Downgrading to 2.0.3 fixes the issue. I tried to setup a simple project to reproduce but could not reproduce the exact issue, so the problem may only appear in a complex solution with 10+ projects in it.

/root/.nuget/packages/microsoft.orleans.orleanscodegenerator.build/2.0.4/build/Microsoft.Orleans.OrleansCodeGenerator.Build.targets(60,5): error MSB4062: The "Orleans.CodeGeneration.GetDotNetHost" task could not be loaded from the assembly /root/.nuget/packages/microsoft.orleans.orleanscodegenerator.build/2.0.4/build/../tasks/netcoreapp2.1/Orleans.CodeGeneration.Build.dll. Assembly with same name is already loaded Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

ReubenBond commented 6 years ago

@mikkoairaksinen can you confirm that all versions of the code generator package are at identical versions?

mikkoairaksinen commented 6 years ago

The code generator package was set to 2.0.4 in both GrainInterfaces and GrainImplementations. I started digging for other mismatches and found that the GrainInterfaces had the TargetFramework set to netstandard2.0 while the GrainImplementations was targeting netcoreapp2.1. I changed the GrainInterfaces to also target netcoreapp2.1 and the error disappeared.

ReubenBond commented 6 years ago

Ok, that makes sense to me. It's an issue for sure. There's a PR which is out that fixes it but possibly the particular fix should be implemented in the current code generator, too.

What's happening is that the MSBuild Task Asm used to find where the dotnet executable lives exists in each of the different code generator builds (one for each target framework) and yet only one task can be loaded for a given name. We should instead out that task into a single .NET Standard assembly and always use that.

ishowfun commented 5 years ago

I got the same problem. When I tried built on windows,centos7,both successed. Only build failed in docker created by gitlab-ci runner. 1.The image: microsoft/dotnet:2.1.500-sdk-alpine (had tried 2.1.500-sdk,2.1-sdk,etc..). 2.Not all projects failed.Only a few graininterface did. 3.Success on single building of every failed csproj. @ReubenBond

ReubenBond commented 5 years ago

As a work-around, try using the new code generator package, Microsoft.Orleans.CodeGenerator.MSBuild. That is a replacement for the other package (don't install both).

ishowfun commented 5 years ago

@ReubenBond I was using Microsoft.Orleans.CodeGenerator.MSBuild. I don't understand why it's successed by single building.It's seemed not much different with solution building.

ReubenBond commented 5 years ago

@ishowfun are all projects using the same package/version? What target framework are each of the projects building for?

ishowfun commented 5 years ago

@ReubenBond yes,all projects using same package and building for same framework,I checked every one.I saw another answer from you and it worked for me.

ReubenBond commented 5 years ago

Very interesting, @ishowfun. Could you build your project with /bl (binary log) and send me the resulting .binlog file?

ishowfun commented 5 years ago

@ReubenBond It's such weird! I rolled all codes back and the docker container built it successful!I'm confused now. This binlog was made by my last building.I cannot repro it. the failure

ReubenBond commented 5 years ago

@ishowfun it's possible that some outdated assembly was present and it was breaking your build.

ishowfun commented 5 years ago

@ReubenBond I built this solution in gitlab docker runner.Maybe I should clear the solution first,not sure about that.

ReubenBond commented 5 years ago

Closing for now. I think this is likely no longer an issue