cake-build / cake

:cake: Cake (C# Make) is a cross platform build automation system.
https://cakebuild.net
MIT License
3.89k stars 726 forks source link

Cannot build tests for Cake in Visual Studio for Mac #1920

Open johankson opened 6 years ago

johankson commented 6 years ago

What You Are Seeing?

Cannot build tests for cake on Mac OS X

What is Expected?

Package restore cannot be performed

What version of Cake are you using?

Are you running on a 32 or 64 bit system?

64-bit

What environment are you running on? Windows? Linux? Mac?

Mac

Are you running on a CI Server? If so, which one?

No

How Did You Get This To Happen? (Steps to Reproduce)

  1. Clone the cake repo
  2. Build tests using Visual Studio for Mac

Output Log

Incompatible packages: 1

patriksvensson commented 6 years ago

@johankson Thanks for reporting this.

Since no one (afaik) in the Cake team owns a mac, we would rely on the community to provide a fix for this.

patriksvensson commented 6 years ago

@johankson I updated the title of the issue.

bjorkstromm commented 6 years ago

I had a friend with Mac test this, and this is the error he got

Package System.Runtime.Loader 4.3.0 is not compatible with net46 (.NETFramework,Version=v4.6) / win-x86. Package System.Runtime.Loader 4.3.0 supports:
  - monoandroid10 (MonoAndroid,Version=v1.0)
  - monotouch10 (MonoTouch,Version=v1.0)
  - net462 (.NETFramework,Version=v4.6.2)
  - netstandard1.5 (.NETStandard,Version=v1.5)
  - xamarinios10 (Xamarin.iOS,Version=v1.0)
  - xamarinmac20 (Xamarin.Mac,Version=v2.0)
  - xamarintvos10 (Xamarin.TVOS,Version=v1.0)
  - xamarinwatchos10 (Xamarin.WatchOS,Version=v1.0)

Seems like conditionals is broken in VS4MAC https://developercommunity.visualstudio.com/content/problem/83448/vs-mac-preview-does-not-support-csproj-condition-f.html

sgrassie commented 6 years ago

I've just been looking at this.

The solution builds find from the terminal, as you would expect, but does still fail to build in Visual Studio Professional 2017 for Mac Version 7.3.3 (build 12). Weirdly, it did say that the build succeeded at first, but then I looked in the package console and found the above error still there. Cleaning and building individual projects gave me some compilation errors, which I resolved by upgrading all the projects to net462, and installing a couple of nuget packages. The details are all in a branch here: https://github.com/sgrassie/cake/tree/investigate-test-building-on-mac

The bug that @mholo65 references above is still "under investigation", and does still seem to be a problem.

I definitely believe that this is not a problem with any source code in Cake, and given that it builds and executes tests ok from the terminal, I think this issue should be closed.

bjorkstromm commented 4 years ago

@devlead @gep13 can you verify if this is still an issue and close if not. Thanks!

gep13 commented 4 years ago

@mholo65 Using the latest version of Visual Studio for Mac:

image

I was able to build the Cake Solution, without any problems, and also to run the Unit Tests for the solution:

image

There was one failing test, which failed with the error:

Running Cake.Tests.Cake.Common.Tests.Cake.Common.Tests.CrossCutting.ToolSettingsTests.Tool_settings_collection_properties_must_be_initialized ...
System.Reflection.ReflectionTypeLoadException : Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown.
Could not load type of field 'Xunit.Runner.VisualStudio.VsDiscoverySink:Hasher' (17) due to: Could not load file or assembly 'Windows.Foundation.UniversalApiContract, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.Result message:
System.Reflection.ReflectionTypeLoadException : Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown.
Could not load type of field 'Xunit.Runner.VisualStudio.VsDiscoverySink:Hasher' (17) due to: Could not load file or assembly 'Windows.Foundation.UniversalApiContract, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

But I think that is more to do with the Test itself, rather than anything else.

I think this issue can be closed.

patriksvensson commented 4 years ago

@gep13 That test is problematic in VS2019's test runner as well. I think we need to look into that in general, so it got nothing to do with VS for Mac per se 👍