- VSTest Console Runner now included with Visual Studio for Mac
- Allows xUnit tests to be supported for non .NET Core projects
- Renamed ASP.NET Core Project Templates
- New ASP.NET Core F# Project Templates Added
- Support Backslash in Project Template Primary Output Path
- Support NuGet Restore MSBuild Properties
- Fixed transitive project references not supported
VSTest Console Runner
Previous versions of Visual Studio for Mac would use dotnet vstest, included with the .NET Core SDK, to run unit tests for .NET Core projects. Now Visual Studio for Mac includes the VSTest Console runner and uses that instead of using the .NET Core SDK.
The standalone VSTest Console runner allows other project types, not just .NET Core projects, to be supported. Visual Studio for Mac can now run xUnit tests for .NET Framework projects. Previously only NUnit was supported.
Let us take a look at using xUnit in a .NET Framework project.
First create a .NET Framework Library project by opening the New Project dialog and selecting Library from the Other – .NET – General category.
Install the following NuGet packages into the project.
Edit MyClass.cs and add some xUnit tests, as shown below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Building the project should then show the xUnit tests in the Unit Tests window.
Note that, due to a bug in Visual Studio for Mac, the tests may not appear in the Unit Tests window if the xunit.runner.visualstudio was not available in the local machine’s NuGet package cache when it was added to the project. Closing and re-opening the solution should allow the tests to be discovered.
The tests can then be run or debugged in the usual way.
Currently MSTest is not yet supported in .NET Framework projects. The tests are discovered but they fail to run with an access denied error message:
An exception occurred while invoking executor 'executor://mstestadapter/v2': Access to the path "/TestResults" is denied.
Renamed ASP.NET Core Project Templates
The ASP.NET Core template names displayed in the New Project dialog have been changed to be more consistent with Visual Studio on Windows.
- ‘ASP.NET Core Web App (Razor Pages)’ renamed to ‘ASP.NET Core Web App’
- ‘ASP.NET Core Web App’ renamed to ‘ASP.NET Core Web App (MVC)’
Visual Studio uses (Model-View-Controller) but the shorter MVC is used by Visual Studio for Mac.
New ASP.NET Core F# Project Templates Added
The following ASP.NET Core F# project templates are now available from the New Project dialog.
- ASP.NET Core Empty
- .NET Core 1.x and 2.0
- ASP.NET Core Web API
- .NET Core 2.0 only
Support Backslash in Project Template Primary Output Path
The template.json file used by the new templating engine uses a primaryOutputs property for projects and files. If the paths used contained backslashes then the project was not added to the solution.
1 2 3 4
Now the paths have the backslashes replaced with forward slashes if the current platform does not support backslash as a path separator.
Support RestoreAdditionalProjectFallbackFolders MSBuild Property
The RestoreAdditionalProjectFallbackFolders MSBuild property is read and appended to the list of fallback folders stored in the project.assets.json file. The .NET Core 2.0 SDK will set this MSBuild property to point to the NuGet package fallback folder that is installed with the SDK. This will be used to resolve NuGet packages first before downloading them to the ~/.nuget/packages folder.
Support RestoreAdditionalProjectSources MSBuild Property
The RestoreAdditionalProjectSources MSBuild property can be used to add additional package sources to the existing list of sources used to resolve packages.
Support RestoreFallbackFolders MSBuild Property
The RestoreFallbackFolders MSBuild property can be used by project that uses PackageReferences to define a set of package fallback folders that will override any specified in the NuGet.Config file. It can also be used to clear any pre-defined fallback folders by specifying ‘clear’ as its value. Note that this value does not affect any folders defined by RestoreAdditionalProjectFallbackFolders which will be appended even if RestoreFallbackFolders is set to ‘clear’.
Support RestorePackagesPath MSBuild Property
The RestorePackagesPath MSBuild property can be used to override the global packages folder location when a project uses a PackageReference.
Support RestoreSources MSBuild property
The RestoreSources MSBuild property can be used to override the sources defined by any NuGet.Config file. Any sources defined in the RestoreAdditionalProjectSources MSBuild property will still be appended to the list of sources if RestoreSources is defined.
Fixed Transitive Project References not supported
With three .NET Core projects, LibC referencing LibB referencing LibA, the types defined by LibA were not available to LibC unless it was directly referencing LibA. In Visual Studio for Mac 7.3 the types defined by LibA are available to LibC without LibC directly referencing LibA.
Portable Class Library projects can now be referenced by .NET Core projects
Portable Class Library (PCL) projects could not be referenced by .NET Core projects or .NET Standard projects. The Edit References dialog would show “Incompatible target framework” for the PCL project when trying to add the reference.
Visual Studio for Mac now has the same behaviour as Visual Studio on Windows where a .NET Standard project can reference any PCL project.
Fixed MSBuild Update item not removed from project
If a file was deleted from a project, or removed without deleting, and the file was the last file for a particular wildcard include, the Update item for the file was not being removed from the project.
Fixed MSBuild Remove item not added when Update item exists
With a project that contained a single .cs file, and that file had an Update item defined, when the file was removed from the project, without deleting it, a Remove item was not being added to the project for the file.
Fixed Remove item not being added when file excluded from project
When the last file was removed from the project, but not deleted, an MSBuild Remove item was not added to the project for the file.
- Create a .NET Standard 2.0 project.
- Right click Class1.cs and select Remove.
- Select Remove from Project in the dialog that opens.
- Close and re-open solution.
The Class1.cs file was still shown in the Solution window when it should have been removed. The project file did not have a Compile remove item for Class1.cs when it should have been added:
<Compile Remove="Class1.cs" />
Deleting a XAML file left an MSBuild Remove item in project file
When a .xaml file in a project was deleted the associated Remove MSBuild item, if it was present, was not being removed from the project file.
- Create a new .NET Standard 2.0 project.
- Add Xamarin.Forms 2.3 NuGet package.
- Add a new Content Page with Xaml file using the New File dialog.
- In the Solution window select the .xaml file and delete it.
All MSBuild items associated with the .xaml file should have been removed from the project file but instead a None item would remain.
<None Remove="MyPage.xaml" />
Fix MSBuild remove item not added when adding a XAML file
Adding a new .xaml file to a project was not adding a None Remove item for the .xaml file to remove it from the default wildcard include for all files.
<None Remove="MyNewPage.xaml" />
On reloading the solution the Solution window would show two .xaml files – one EmbeddedResource item and one None item.
Fixed MSBuild condition evaluation when using Czech locale
With the primary operating system language set to Czech, creating a new .NET Core project would result in the project having a target framework of net461.
The problem was that Single.TryParse was returing true for an empty string when the machine’s culture was ‘cs-CZ’. This was causing the MSBuild condition evaluation to be treated as a boolean comparison incorrectly in some cases. The condition below would return false even though the property was not defined and both sides of the condition were empty strings:
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == ''">
This was causing the TargetFrameworkIdentifier to not be set for .NET Core projects so the default of .NETFramework was being used.
Re-evaluate AppliesTo condition on capability change
Fixed the AppliesTo attribute not attaching a project extension to a project after a NuGet package restore enabled a project capability. The AppliesTo attribute allows a project extension to be associated to a project based on its capabilities.
If the project extension uses an AppliesTo attribute which is initially false and then a new project capability is added, and the project is re-evaluated, the AppliesTo attribute is now re-evaluated. This will then cause the project extension to be attached to the project. If the project extension was attached to the project and the project capability is removed then the project extension will now be removed when the project is re-evaluated.
Fixed being unable to run a new Azure Functions project
Creating a new Azure Functions project would result in being unable to run the project until the solution was closed and re-opened again. After the NuGet packages are restored the project can be run but this information was not updated in Visual Studio for Mac.
Now after a NuGet package restore, when re-evaluating the project, the solution startup item is updated if there is no startup item already defined.
When the project capability is removed, due to a NuGet package being uninstalled, and the project can no longer be run the startup item will be updated if it was previously set to be this project.