Closed MikeHardman closed 6 years ago
Hi @MikeHardman, I'll try to fix it.
The exception message isn't what I would have expected (it should be able to load that task, at least), but maybe MSBuild is scanning the whole assembly and then hitting the MarshalByRefObject
base class of CodeGenerator
. Hopefully we can fix it soon.
@MikeHardman I don't have an OS X machine to repro on, but I was unable to repro on my linux host - the project built without issue. Are you using an IDE or building from command line? If you're using an IDE, which one?
Actually I think this is VS Mac only, works using the CLI for me but running/building in VS fails with this error.
@martinothamar I might have to find a MacBook so I can debug this
I could have a look tomorrow, if you havent gotten to it yet
I won't have, so if you can look then that would be fantastic. I'm unsure what would cause the error in the original post
Using msbuild on Mac OS: Microsoft (R) Build Engine version 15.4.0.0 (master/f296e67b Wed Oct 25 12:26:03 EDT 2017) for Mono
nuget restore OrleansCrossPlatform.sln
msbuild OrleansCrossPlatform.sln
^ Reproduces the issue.
Tried removing the MarshalByRefObject
base class from CodeGenerator
, then it throws a different error:
"/Users/martinothamar/dev/orleans/OrleansCrossPlatform.sln" (default target) (1) ->
"/Users/martinothamar/dev/orleans/src/Orleans.Core/Orleans.Core.csproj" (default target) (2) ->
(GenerateOrleansCode target) ->
/Users/martinothamar/dev/orleans/src/Orleans.CodeGeneration.Build/build/Microsoft.Orleans.OrleansCodeGenerator.Build.targets(54,5): error MSB4018: The "Orleans.CodeGeneration.GetDotNetHost" task failed unexpectedly. [/Users/martinothamar/dev/orleans/src/Orleans.Core/Orleans.Core.csproj]
/Users/martinothamar/dev/orleans/src/Orleans.CodeGeneration.Build/build/Microsoft.Orleans.OrleansCodeGenerator.Build.targets(54,5): error MSB4018: System.TypeLoadException: Could not resolve type with token 01000024 (from typeref, class/assembly System.AppDomain, System.Runtime.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) [/Users/martinothamar/dev/orleans/src/Orleans.Core/Orleans.Core.csproj]
/Users/martinothamar/dev/orleans/src/Orleans.CodeGeneration.Build/build/Microsoft.Orleans.OrleansCodeGenerator.Build.targets(54,5): error MSB4018: at Orleans.CodeGeneration.GetDotNetHost.Execute () [0x00001] in <a6026c99e4c742a7a14ce0539e831b66>:0 [/Users/martinothamar/dev/orleans/src/Orleans.Core/Orleans.Core.csproj]
/Users/martinothamar/dev/orleans/src/Orleans.CodeGeneration.Build/build/Microsoft.Orleans.OrleansCodeGenerator.Build.targets(54,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00023] in <76dd0031e0df4aa99d9befb4c4585c69>:0 [/Users/martinothamar/dev/orleans/src/Orleans.Core/Orleans.Core.csproj]
/Users/martinothamar/dev/orleans/src/Orleans.CodeGeneration.Build/build/Microsoft.Orleans.OrleansCodeGenerator.Build.targets(54,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder+<ExecuteInstantiatedTask>d__26.MoveNext () [0x0022d] in <76dd0031e0df4aa99d9befb4c4585c69>:0 [/Users/martinothamar/dev/orleans/src/Orleans.Core/Orleans.Core.csproj]
So the task loads but crashes when it tries to interact with AppDomain? I don't see System.Runtime.Extensions installed, does it need to be? Not sure how to debug this tbh.
Crazy stuff, @martinothamar, thanks for the repro. I managed to repro on Linux using similar steps.
I'll try to debug and fix if I can find time. For the time being, dotnet build
/dotnet msbuild
is the way to go.
If anyone else is able to advise on what might cause these issues, please weigh in and feel free to grab the issue.
@ReubenBond Do you still need to debug on a mac? I can give you remote access to one from Saturday.
JetBrains Ride compiles my Orleans project on a mac where VS Mac won't. (you can get any Resharper discount you have built up applied to a Ride subscription)
@jamiemitchellconsultants I can do it on my linux host, but I haven't found the time yet. It seems to be a Mono issue
We're having the same issue when using AppCenter to build the project
@nh43de which runtime is being used to build your project there, are you able to provide some diagnostics?
Having a same issue here on MacBook Pro. Builds fine from a command line, but an error in VS Mac.
Same issue for me on VS Mac and JetBrains Rider.
Microsoft.Orleans.OrleansCodeGenerator.Build.targets(56, 5): [MSB4062] The "Orleans.CodeGeneration.GetDotNetHost" task could not be loaded from the assembly /Users/x/.nuget/packages/microsoft.orleans.orleanscodegenerator.build/2.0.3/build/../tasks/netcoreapp2.0/Orleans.CodeGeneration.Build.dll. Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown. Confirm that the
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. Dolores.Core: [MSB4062] The "Orleans.CodeGeneration.GetDotNetHost" task could not be loaded from the assembly /Users/x/.nuget/packages/microsoft.orleans.orleanscodegenerator.build/2.0.3/build/../tasks/netcoreapp2.0/Orleans.CodeGeneration.Build.dll. Could not resolve type with token 0100001e (from typeref, class/assembly System.MarshalByRefObject, System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) Confirm that the
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.
Same issue for me on VS for MAC
The same issue for me( VS for MAC
This is a tricky issue to reproduce for me, since I don't have a Mac (and my Linux box died 😢). I would guess that the issue is related to our MSBuild targets or perhaps we need to specifically target Mono in the code generator package, but I'm unsure.
I'd recommend using .NET Core and VS Code as a workaround, does that work?
I am working on fixing this in some capacity, via a new code generator which is more cross-platform/cross-runtime than the existing one (a single .NET Core AnyCPU/AnyPlat executable). That ought to rectify these issues and many more. If anyone with a Mac wants to pair up on this then I would be more than happy to dedicate some time to fixing it sooner.
@ReubenBond I have a repro on my mac box. If you'd like, I'd be happy to host a screenshare where you can drive and see it in action.
@ReubenBond When do expect the new code generator to be available for testing?
@jsteinich I don't have an ETA at the moment, sorry. I would say that we wont have a replacement in the v2.1.0 timeframe, but hopefully it's soon after.
I have observed the same issue with Rider 2018.1.4 on Ubuntu 16.04. (Orleans.Core.Abstraction 2.0.0 and Orleans.OrleansCodeGenerator.Build 2.0.4)
Microsoft.Orleans.OrleansCodeGenerator.Build.targets(60, 5): [MSB4062] The "Orleans.CodeGeneration
.GetDotNetHost" task could not be loaded from the assembly /home/mehmet/.nuget/packages/microsoft.or
leans.orleanscodegenerator.build/2.0.4/build/../tasks/netcoreapp2.0/Orleans.CodeGeneration.Build.dll
. Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown. Confirm that the <Us
ingTask> 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.
Caelex.Interfaces: [MSB4062] The "Orleans.CodeGeneration.GetDotNetHost" task could not be loaded f
rom the assembly /home/mehmet/.nuget/packages/microsoft.orleans.orleanscodegenerator.build/2.0.4/bui
ld/../tasks/netcoreapp2.0/Orleans.CodeGeneration.Build.dll. Could not resolve type with token 010000
1e (from typeref, class/assembly System.MarshalByRefObject, System.Runtime, Version=4.2.0.0, Culture
=neutral, PublicKeyToken=b03f5f7f11d50a3a) 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.
Builds perfectly fine when using dotnet build
in a terminal. Definitely caused by something to do with Mono MSBUILD since the dotnet one doesn't have this issue.
This build time error disappeared when I switched from Mono's msbuild to native dotnet one.
I came across this issue as well on macOS. It was only an issue if i ran dotnet build
from the directory containing the .sln
file, if I ran dotnet build
(and dotnet run
) from the .csproj
folder is worked as expected.
@brendanmckenzie What version is this with. Have you tried using Microsoft.Orleans.CodeGenerator.MSBuild
package instead of Microsoft.Orleans.OrleansCodeGenerator.Build
?
@sergeybykov now that I have it working I'm unable to make it not work. Even after running dotnet clean
and clearing out my ~/.nuget/packages folder.
When attempting to build a 2.0.0 project on MacOS Sierra we get the attached Msbuild error: https://i.imgur.com/ikpdTq1.png
The text if the image won't load is as follows:
The "Orleans.CodeGeneration.GetDotNetHost" task could not be loaded for the assembly '.../Orleans.CodeGeneration.Build.dll'. Could not resolve type with token 0100001e (from typeref, class/assembly System.MarshalByRefObject, System.Runtime, Version=4.2.0.0, Culture=neutral....
It looks like that goes on to cause a ReflectionTypeLoadException in MSBuild.