Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?

.NET Core 2.0 SDK Preview 1 Support in Visual Studio for Mac

This document covers the steps required in order to use build and run .NET Core 2.0 and .NET Standard 2.0 projects with Visual Studio for Mac.

Existing project templates target .NET Core 1.1

If only the .NET Core 2.0 SDK is installed then the projects will fail to run due to the 1.1 runtime being unavailable. To target .NET Core 2.0 the TargetFramework in the project will need to be edited to target netcoreapp2.0 or netstandard2.0. Alternatively the dotnet cli installed with the .NET Core 2.0 SDK can be used to create the project with the correct dependencies and target framework.

.NET Core App 2.0 Project

Package restore will fail to resolve 'Microsoft.NETCore.App (>= 2.0.0)'.

The RuntimeFrameworkVersion needs to be added to the project for restore to complete successfully.

<Project Sdk="Microsoft.NET.Sdk"> 
  
  <PropertyGroup> 
     <OutputType>Exe</OutputType> 
     <TargetFramework>netcoreapp2.0</TargetFramework> 
     <RuntimeFrameworkVersion>2.0.0-preview1-002111-00</RuntimeFrameworkVersion> 
   </PropertyGroup> 
  
</Project>

.NET Standard 2.0 Project

By default the .NETStandard.Library 1.6.1 package will be used since the .NET Core sdk files that ship with Mono's MSBuild define that as the default version.

A workaround is to add the NETStandardImplicitPackageVersion to the project.

<Project Sdk="Microsoft.NET.Sdk"> 
  
  <PropertyGroup> 
     <TargetFramework>netstandard2.0</TargetFramework> 
     <NETStandardImplicitPackageVersion>2.0.0-preview1-25301-01</NETStandardImplicitPackageVersion> 
   </PropertyGroup> 
  
</Project>

Is there a way make VS4Mac(v7.0.1) support dotnet standard 2.0 packages in dotnet core app 2.0 project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment