Search code examples
.net-coremsbuildvisual-studio-mac

VS for Mac 2017 building with .NET Core SDK instead of Mono


I have several solutions that target some combination of .NET Standard 2.0 or .NET Core 2.1. I have the latest .NET Core 2.1 SDK installed.

When I build them via Visual Studio for Mac, I notice it is using the Mono build tools instead of dotnet such as csc.exe:

Target CoreCompile:
    /Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/msbuild/15.0/bin/Roslyn/csc.exe 

Is there an option or some other property needs changed so that it can use the SDK instead of the Mono tools?


Solution

  • There is no option to use dotnet for building within Visual Studio for Mac. It uses msbuild. If you really want to do that you would need to bypass the built-in support and use of msbuild that VS Mac provides.

    VS Mac uses msbuild that ships with Mono because it supports more target frameworks (e.g. Xamarin.iOS, Xamarin.Android) than the .NET Core SDK's MSBuild does. Note that VS on Windows takes a similar approach where it uses a desktop MSBuild to run builds and does not use dotnet build.

    However Mono's MSBuild still uses the various MSBuild sdk target files that are shipped with the .NET Core SDK. There is an MSBuild sdk resolver that ships with Mono that allows the .NET Core SDK msbuild targets to be found and used.

    Also note that Mono's MSBuild includes some parts of the .NET Core SDK so it can compile .NET Standard projects without needing the .NET Core SDK.