asynkron / protoactor-dotnet

Proto Actor - Ultra fast distributed actors for Go, C# and Java/Kotlin
http://proto.actor
Apache License 2.0
1.71k stars 285 forks source link

Building / developing on mac #223

Closed tomliversidge closed 4 years ago

tomliversidge commented 7 years ago

Currently the solution does not build on macOS and does not load in Visual Studio for Mac. This is because we are setting the target frameworks as net452 and netstandard1.5. When running the build.sh script, projects fail on building for net452

We can fix this by adding in a hint for MSBuild to find the mono runtime to build against.

<PropertyGroup Condition="'$(TargetFramework)' == 'net452' AND '$(OS)' == 'Unix'">
<FrameworkPathOverride>/Library/Frameworks/Mono.framework/Versions/5.0.0/lib/mono/4.5.2-api/</FrameworkPathOverride>
  </PropertyGroup>

This is the location of mono if installed with Xamarin Studio. If installed through brew, it will be different. See https://github.com/dotnet/netcorecli-fsc/wiki/.NET-Core-SDK-rc4#using-net-framework-as-targets-framework-the-osxunix-build-fails for details. If we do this we should have a nice way to determine where mono is installed. NOTE Visual Studio for mac doesn't seem to support having multiple target frameworks.

An alternative way to fix this is to remove net452 from the target frameworks. We can just target netstandard and it builds on mac, and can be opened in Visual Studio for mac. If we go down this route we would lose support for certain versions of full framework, and we need to decide if we want to target each project to the same version of netstandard or go for the minimum required for each project:

Proto.Actor netstandard1.2 Proto.Mailbox netstandard1.2 Proto.Router netstandard1.3 Proto.Remote netstandard1.5 etc...

If we lower things this way, someone with a full framework 4.5.1 app could use Proto.Actor and Proto.Mailbox for in-memory, single machine app only, but someone running 4.6.0 could use Proto.Router, as well as Martin and RavenDB persistence, as these can also both be lowered to netstandard1.3

In general though, would people find this micro-style versioning more annoying / confusing than just saying "Proto requires X" and stick to a single target? Being more micro versioned would mean we could support certain scenarios in more places, but could be confusing.

Outstanding issues to investigate:

adamhathcock commented 7 years ago

I wish you there was a better flag to ignore certain frameworks with msbuild.

Cake scripting can do the desired thing and filter out full framework when non windows which is what I've done in the past.

tomliversidge commented 7 years ago

Multiple target frameworks are not supported on Visual Studio for mac:

https://developercommunity.visualstudio.com/content/problem/56451/projects-with-multiple-targetframeworks-doesnt-loa.html

https://bugzilla.xamarin.com/show_bug.cgi?id=55508

tomliversidge commented 7 years ago

@adamhathcock do you have any example cake scripts?

adamhathcock commented 7 years ago

Sorry. I probably spoke too soon.

What I did before with project.json was read the frameworks out of the json then filter out non-standard ones when it's not windows. However, the issue is now, how do we list the framework targets with csproj?

I don't readily know if that's possible. I guess you could do some XML parsing. Cake's settings for msbuild doesn't have a framework target on it anymore anyway: http://cakebuild.net/api/Cake.Common.Tools/DotNetBuildSettings/C267BF7E

I think what you have to do is create multiple configurations in the solution. You can make a non-windows configuration and have it only build certain frameworks? Maybe that won't work until 15.3 when VS2017 gets multi targetting support.

tomliversidge commented 7 years ago

Adding

export FrameworkPathOverride=$(dirname $(which mono))/../lib/mono/4.5.2-api/

to build.sh seems to work :)

tomliversidge commented 7 years ago

This is now failing again for me on my mac. Not sure what has changed between the work originally done on this ticket and now. The error is:

"The path '/Users/tomliversidge/Code/tomliversidge/protoactor-dotnet/tests/Proto.Actor.Tests/bin/Release/net452' specified in the 'TestAdapterPath' does not contain any test adapters, provide a valid path and try again."

Looks like the build is failing when trying to run tests that were built for net452. The tests for dotnetcore work fine. Did this build script always try and run tests for net452? I'm confused as to why it has started failing now - did cake update? did dotnet tooling update?

This might be a dotnet test problem. The Jetbrains Rider survival guide says: "Rider does not support .NET Core tests that target .NET Framework, but run on Mono. This is a limitation of dotnet test, which does not work correctly in this situation on Mono. We are investigating workarounds."

We might be able to target a specific framework (dotnetcore) when running on mac? dotnet test can take the following parameter:

-f|--framework <FRAMEWORK>
Looks for test binaries for a specific framework.

@AsynkronIT/developers anyone else have a mac to try and test this please to see if it is just my machine that it has broken on? :)

adamhathcock commented 7 years ago

I can confirm this is a CLI problem. Running dotnet test "tests/Proto.Actor.Tests/Proto.Actor.Tests.csproj" --configuration Release --no-build from the base directory results in the same.

We could attempt to adjust the cake script to for the frameworks when running non-windows

alexeyzimarev commented 6 years ago

I don't anyone really uses netstandard1.5.

I am not sure why any reference to Mono is needed in csproj file because, for example, MassTransit doesn't have such things in the csproj file and it works everywhere: https://github.com/MassTransit/MassTransit/blob/develop/src/MassTransit/MassTransit.csproj

cpx86 commented 4 years ago

All projects now target .NET Standard or Core, so this should be solved now.