Matt Ward

.NET Core Support in Visual Studio for Mac 7.1

New Features

  • .NET Core 2.0 support
  • Target framework selection for new projects
  • New project templates
  • .NET Core Runtimes and SDKs displayed in About Dialog
  • Improved support for multi target framework projects

More information on all the new features and changes in Visual Studio for Mac 7.1 can be found in the release notes.

.NET Core 2.0 Support

Visual Studio for Mac 7.1 adds support for .NET Core 2.0 and .NET Standard 2.0.

The .NET Core 2.0 SDK needs to be installed separately.

Target Framework Selection for New Projects

If a project template supports multiple target frameworks, and the corresponding framework is available, then the New Project dialog will allow the framework to be selected before the project is created.

New .NET Core target framework selection

Visual Studio for Mac includes project templates for .NET Core 1.0, 1.1 and 2.0 as well as for .NET Standard versions 1.0 through to 2.0.

To be able to create projects that target .NET Core 2.0 or .NET Standard 2.0 the .NET Core 2.0 SDK needs to be installed.

New Project Templates

The following project templates have been added:

  • ASP.NET Core Web App (Razor Pages)
    • Available if .NET Core 2.0 SDK is installed.
  • Class Library
    • Targets .NET Core instead of .NET Standard.
  • MSTest

Some project templates do not support all the target framework versions. For example, the ASP.NET Core Web App (Razor Pages) only supports .NET Core 2.0, so this template will only be displayed if .NET Core 2.0 SDK is installed.

The F# project templates have some restrictions on what target frameworks they support. The F# .NET Standard project templates do not support selecting .NET Standard versions below 1.6. The F# Class Library project only supports .NET Core 2.0.

.NET Core Runtime and SDKs displayed in About Dialog

The About dialog will now display the .NET Core runtimes and SDKs that are installed on the local machine.

.NET Core runtime and SDK information in About dialog

Improved Support for Multi Target Framework Projects

SDK style projects that target multiple frameworks can now be opened in Visual Studio for Mac 7.1 and will show source files as well as NuGet package dependencies.

The project will be treated as though it only has one target framework which is the first one specified in the TargetFrameworks property in the project file.

Please note that currently the support for multiple target frameworks is limited in comparison with Visual Studio on Windows.

Bug Fixes

ASP.NET Core Web API project does not open API url on launching browser

When an ASP.NET Core Web API project was run it would open a blank web page in the browser instead of a page that showed the api values. Now when a new ASP.NET Core Web API project is run the http://localhost:<port>/api/values url is launched in the browser so the API values will be displayed.

Unable to run or debug ASP.NET Core project with empty SDK directory

If there was an empty directory inside the .NET Core SDK directory /usr/local/share/dotnet/sdk then it was not possible to run or debug an ASP.NET Core web project

If the .NET Core SDK MSBuild files were not found in the SDK directory then the project’s OutputType was not read and would result in the project being treated as a library project. This could also occur if only the .NET Core runtime is installed.

Shared project files shown for .NET Core project in Solution window

When a .NET Core project referenced a shared assets project the files from the shared project were incorrectly being displayed in the .NET Core project in the Solution window.

Fix generated code for resource files in .NET Core projects

Adding a resx file to a .NET Core 1.x or .NET Standard 1.x project would result in code being generated that could not be compiled.

Projects that target .NET Core App 1.0, 1.1, or .NET Standard below version 2.0 cannot compile code that uses typeof(Resources).Assembly which was being generated by the ResXFileCodeGenerator. If these target frameworks are used by the project then the code generated by Visual Studio for Mac will now use typeof(Resources).GetTypeInfo().Assembly which is supported.

.NET Core 2.0 and .NET Standard 2.0 do not need to use GetTypeInfo so the code generated for these frameworks has not been changed.

Fix new resource file not added as Update item in Sdk projects

Adding a new resource file to a .NET Core project would add the .resx file and the .Designer.cs file as Include items instead of an Update items.

  <EmbeddedResource Include="Resources.resx">
  <Compile Include="Resources.Designer.cs">

This then caused the build to fail since these files are already included by the .NET Core SDK.