Matt Ward

NuGet Support in Visual Studio for Mac 8.7

Changes

  • NuGet 5.7 support
  • .NET Core 3.1.401 support
    • Supported in Visual Studio for Mac 8.7.1
  • .NET 5 preview 6 and 7 support
  • Fixed tests not discovered by VS Test adapter for imported NuGet packages
  • Fixed dependent projects not being restored after project reference added
  • Fixed SDK resolution errors with vstool

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

NuGet 5.7 support

NuGet 5.7.0.6702 is now included with Visual Studio for Mac 8.7.

.NET Core 3.1.401 support

The NuGet packages shown in the Solution window in the Dependencies folder would not show child dependencies when .NET Core 3.1.401 SDK was installed.

The ResolvePackageDependenciesDesignTime MSBuild target’s behaviour changed in .NET Core 3.1.401 to no longer return the full set of NuGet dependencies and now returns only the top level depdnencies.

The logic that was originally in this design time MSBuild target has been added to Visual Studio for Mac so the full tree structure of the NuGet package dependencies can be displayed in the Solution window.

Note that .NET Core 3.1.401 is supported in Visual Studio for Mac 8.7.1

.NET 5 preview 6 and 7 support

Restoring an ASP.Core project targeting .NET 5 would fail with an error when the ResolvePackageAssets task was run.

1
2
3
4
/usr/local/share/dotnet/sdk/5.0.100-preview.6.20304.10/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(5,5):
Error MSB4018: The "ResolvePackageAssets" task failed unexpectedly.
System.MissingFieldException: Field not found: string NuGet.ProjectModel.LockFileItem.AliasesProperty Due to: Could not find field in class
  at Microsoft.NET.Build.Tasks.ResolvePackageAssets+CacheWriter.WriteItems[T] (NuGet.ProjectModel.LockFileTarget target, System.Func`2[T,TResult] getAssets, System.Func`2[T,TResult] filter, System.Action`2[T1,T2] writeMetadata) [0x0008e] in <9d95d6a4081d41288f54edb04b336893>:0 

NuGet 5.7 introduced a new AliasesProperty to the LockFileItem class. MSBuild in Mono 6.12 uses NuGet 5.6 build tasks which do not support this new property causing the NuGet restore to fail.

Visual Studio for Mac now includes version 5.7 of the NuGet.Build.Tasks assembly and associated MSBuild targets. These files are copied to Visual Studio for Mac’s MSBuild host when it is created and replace these files originally copied from Mono’s MSBuild.

Note that .NET 5 preview 8 is not supported by Visual Studio for Mac 8.7 but is supported in by Visual Studio for Mac 8.8.

Bug Fixes

Fixed tests not discovered by VS Test adapter for imported NuGet packages

Test adapter NuGet PackageReferences defined in a Directory.Build.props file were not considered by Visual Studio for Mac. This resulted in the Unit Tests window not showing any unit tests. Only when the test adapter PackageReferences were in the main project file would tests be discovered.

Fixed dependent projects not being restored after project reference added

For a new Blazor Web Assembly project (with ASP.NET Core hosted) adding a new Razor library project, and having the Client project reference the library project, would result in build warnings incorrectly displayed for the Server project due to conflicts between the NuGet packages used by the Client because of the new Razor library project reference.

MSB3277: Found conflicts between different versions of "Microsoft.AspNetCore.Components" 

Running a restore for the solution would fix this build warning.

With two SDK style projects referencing each other as follows:

ProjectB –> ProjectA

If a new SDK project was added, and ProjectA referenced it, the restore would only occur for ProjectA not ProjectB. This would mean the Lib project was not available to ProjectB until a restore was run for ProjectB or for the solution. Depending on the NuGet packages used this could result in build warnings.

To fix this all the projects, that reference the project which is modified due to the new project reference, are now restored.

Fixed SDK resolution errors with vstool

vstool is an application that is included with Visual Studio for Mac and provides a way to run some IDE features from the command line. When one of these features used a project that required an SDK provided by NuGet it would fail to resolve and download that SDK.

For example, running the following would fail to resolve SDKs provided by NuGet packages.

vstool gettext-update --sort -f:Main.sln

An error would be reported:

ERROR: Unable to find SDK 'Xamarin.Mac.Sdk'

The NuGet SDK resolver would fail to find the NuGet.Credentials.dll causing vstool to fail.

FileNotFoundException Could not load file or assembly 'NuGet.Credentials, Version=5.6.0.5.

To fix this the NuGet.Credentials.dll is pre-loaded by Visual Studio for Mac so it is available in the AppDomain when vstool is run.

NuGet Support in Visual Studio for Mac 8.6

Changes

  • NuGet 5.6 support
  • Fixed escape key not closing Manage NuGet Packages dialog

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

NuGet 5.6 support

NuGet 5.6.0.6591 is now included with Visual Studio for Mac 8.6.

Bug Fixes

Fixed escape key not closing Manage NuGet Packages dialog

When the search text box had focus pressing the escape key would not close the Manage NuGet Packages dialog as it did in previous versions. A change to fix accessibility of the search text box broke the original behaviour of the dialog.

Manage Global NuGet Folders for Visual Studio for Mac

NuGet supports configuring the location of the following global folders:

  • Global NuGet packages cache
    • ~/.nuget/packages
  • HTTP cache
    • ~/.local/share/NuGet/v3-cache
  • NuGet plugins ache
    • ~/.local/share/NuGet/plugins-cache

The above folder locations can be found by running the following command from Terminal.

nuget locals all -list

Here we will take a look at how these can be configured for use by Visual Studio for Mac 8.5 when running on macOS Catalina.

Configuring Global Packages Folder Only

If only the global packages folder needs to be configured then the simplest way is to define the globalPackagesFolder folder in the ~/.config/NuGet/NuGet.Config file.

1
2
3
4
5
6
7
8
<configuration>
  <config>
    <add key="globalPackagesFolder" value="/Volumes/YourDrive/NuGet/.nuget/packages" />
  </config>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
</configuration>

Visual Studio for Mac will need to be restarted before it picks up any changes to the NuGet.Config file.

Configuring Global Folders with Environment Variables

Visual Studio for Mac will not use environment variables defined in the Bash profile ~/.bash_profile or the Zsh profile ~/.zprofile unless Visual Studio for Mac is run from the Terminal.

open -n "/Applications/Visual Studio.app"

When Visual Studio for Mac is run from the Dock, or from LaunchPad, it does not inherit these environment variables.

Let us take a look at how we can define these NuGet environment variables so that Visual Studio for Mac will use them without having to launch it from the Terminal.

Create the file ~/Library/LaunchAgents/environment.plist containing the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?xml version=“1.0” encoding=“UTF-8”?>
<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “https://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=“1.0”>
<dict>
<key>Label</key>
<string>my.startup</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>launchctl setenv NUGET_PACKAGES /Volumes/YourDrive/NuGet/.nuget/packages
launchctl setenv NUGET_HTTP_CACHE_PATH /Volumes/YourDrive/NuGet/.nuget/v3-cache
launchctl setenv NUGET_PLUGINS_CACHE_PATH /Volumes/YourDrive/NuGet/.nuget/plugins-cache</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

Replace the NuGet paths /Volumes/YourDrive/NuGet/ defined above as required.

Restart macOS to have this Launch Agent run.

After restarting you can check the environment variables are being used by NuGet by using the command line:

nuget locals all -list

Now when Visual Studio for Mac is launched from the Dock, or from LaunchPad, it will use these custom NuGet folders.

More Information

launchctl setenv defines environment variables globally so they are available to all macOS applications launched with launchd.

NuGet Support in Visual Studio for Mac 8.5

Changes

  • NuGet 5.4 support
  • Support Plugin-based NuGet Credential Providers
  • Fixed requests bypassing the native macOS HTTP handler

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

NuGet 5.4 support

NuGet 5.4.0.6315 is now included with Visual Studio for Mac 8.5.

Support Plugin-based NuGet Credential Providers

NuGet credential provider plugins are now supported by Visual Studio for Mac.

Plugins are self-contained executables which provide credentials for NuGet package sources. One example is the Azure Artifacts Credential Provider which Visual Studio for Mac can now use whilst it does not have integrated support for accessing packages sources available from Azure DevOps.

Bug Fixes

Fixed HTTP requests bypassing the native macOS HTTP handler

Restoring or installing a NuGet package into a project that uses PackageReferences was bypassing the native macOS HTTP handler.

This was due to NuGet’s CachingSourceProvider creating its own set of INuGetResourceProviders when it creates a set of new SourceRepository instances. This resulted in the default HttpSourceResourceProvider being used, instead of the custom one provided by Visual Studio for Mac. The default HttpSourceResourceProvider uses Mono’s HttpClientHandler not the native HTTP Client handle NSUrlSessionHandler provided by Xamarin.Mac. This would happen when the Nuget package was was downloaded.

NuGet 5.4 now supports defining custom INuGetResourceProvider factory that is used globally. This is now used by Visual Studio for Mac so all HTTP requests use the native macOS HTTP handler NSUrlSessionHandler.

NuGet Support in Visual Studio for Mac 8.4

Changes

  • Improved accessibility of the Manage NuGet Packages dialog and Add Package Source dialog
  • Fixed updating multiple NuGet packages failing due to restricted version range of a common dependency

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

Accessibility Improvements – Manage NuGet Packages dialog

Voice Over now recognises tabs

The Browse, Installed, Updates and Consolidates tabs are now recognised as tabs by Voice Over. Previously they were being treated as text labels and Voice Over would not announce that a tab could be selected via Control-Option-Space.

Voice Over now announces status messages

The status message that is displayed with the busy spinner image is now announced by Voice Over. When the status message is removed another message is announced by Voice Over to say the loading has completed or, if a search filter was entered, search was completed. If no packages are found when searching this message is also announced by Voice Over.

Improve Voice Over reading of Id label

The Id label has been changed to ID. Using ID allows Voice Over to announce it as I.D. instead of a single word. Note that some Voice Over voices, such as English UK, still announce the text incorrectly. Without changing the label text to be “I.D.” there does not seem to be a way of fixing this for all voices. System Preferences on the Mac can be used to change the pronounciation for certain words if required.

Voice Over now reads first column header in Consolidate tab

The check box to select a project to consolidate was in its own column that had no name. Using Voice Over it was not obvious what this check box was for. Now the check box and the project name are in the same column and Voice Over reads the column header name, the project name and the checkbox state which makes it easier to understand what the list is displaying.

Voice Over now reading associated labels for selected UI control

Labels were not associated with their corresponding UI controls which resulted in them not being read by Voice Over when corresponding UI control was selected.

The package source combo box is now read by Voice Over as ‘Package Sources’. Previously there was no associated label information being read.

Voice Over now reads the label for Search text field. The search text box now shows ‘Search’ as placeholder text.

Voice Over now reading package list information

Voice Over now reads the package information in the list and the check box can be ticked or unticked by using Voice Over. Previously no information was read by Voice Over and the check box could not be accessed.

Keyboard can now be used to move across tabs

Previously it was not possible to tab across the Browse, Installed, Updates or Consolidate tabs.

This change will be in Visual Studio for Mac 8.4.2.

Accessibility Improvements – Add Package Source Dialog

In Preferences – NuGet – Sources, the Add Package Source dialog would lose focus when the Browse button was used. A way to reproduce this is to tab to the Add button, press space, then tab to the Browse button in the Add Package Source dialog, press space, then press escape. The Add Package Source dialog then no longer has focus and tabbing does not work.

This has been fixed by explicitly setting focus back to the parent dialog when a child dialog is closed.

Bug Fixes

Fixed updating multiple NuGet packages failing due to restricted version range of a common dependency

Updating two NuGet package references that have a strict dependency on a single version of another NuGet package, not explicitly added to the project, would fail in the Manage NuGet Packages dialog. This was because the update was being done one NuGet package at a time.

With an Android project that uses Xamarin.Forms this could happen when updating Xamarin.Essentials, an Xamarin.Android.Support.Core.Utils and Xamarin.Forms at the same time. The Xamarin.Android.Support NuGet packages depend on specific versions for their dependencies which can cause the update to fail depending on whether a NuGet package is updated on its own or in a group. The resulting failure would be similar to

1
2
3
Version conflict detected for Xamarin.Android.Support.Collections. Install/reference Xamarin.Android.Support.Collections 28.0.0.3 directly to project to resolve this issue. 
 MyProject.Android -> Xamarin.Android.Support.Core.Utils 28.0.0.3 -> Xamarin.Android.Support.Compat 28.0.0.3 -> Xamarin.Android.Support.Collections (= 28.0.0.3) 
 MyProject.Android -> Xamarin.Essentials 1.2.0 -> Xamarin.Android.Support.CustomTabs 28.0.0.1 -> Xamarin.Android.Support.Collections (= 28.0.0.1).

Updating NuGet packages in the Manage NuGet packages dialog is now done as a batch instead of individually. This allows NuGet to update both NuGet packages so they then use the new strict dependency.

Note that updating all packages in the project from the Solution window does not have this problem since there the packages were already updated together in a batch.

Project System Tools for Visual Studio for Mac

The Project System Tools extension provides MSBuild design-time and build logging for Visual Studio for Mac.

Build Logging window and BinLog tree view

This is based on the Project System Tools available for Visual Studio on Windows and also re-uses code from this extension.

Features

  • Build Logging window
    • Shows a list of builds and design-time builds
  • View MSBuild log output for all builds and design-time builds
  • View MSBuild binary logs for builds
    • Build tab shows a tree view of the build results from the binary log
    • Target Summary tab shows target name, number of calls, timings and file location
    • Task Summary tab shows task name, number of calls, timings and file location

Supports

  • Visual Studio Mac 8.1 or later.

Build Logging Window

To open the Build Logging Window

  • Select View – Pads – Build Logging

Build Logging window

Click the green arrow to enable logging for builds and design-time builds.

To stop the logging click the red square.

To filter the targets use the combo box to restrict the items shown to builds or design time builds, or use the search on the right hand side of the window.

MSBuild Log Output

To open the MSBuild log output

  • Double click the row in the Build Logging window or
  • Right click the row and select Open Log File

Open Log File context menu

MSBuild Log File

The verbosity of the MSBuild log output is configured in Preferences – Projects – Build – Log verbosity.

MSBuild Binary Log

To open a binary log file

  • Right click the row in the Build Logging window and select Open Binary Log File

Note that binary logs are only available when the project or solution is built. Support for design-time build binary logs should be available in Visual Studio for Mac 8.5.

Three tabs are provided by the Project System Tools extension when a binary log file is opened.

  • Build
    • Tree view of the binary log targets and tasks
    • Properties window shows more information about the selected task or target
  • Target Summary
    • Target name
    • Source filename
    • Number of calls
    • Time taken
    • Percentage of total time taken
  • Task Summary
    • Task name
    • Source filename
    • Number of calls
    • Time taken
    • Percentage of total time taken

Build Tab

MSBuild Binary Log File - Build tab

The Build tab shows the run times of the targets and tasks, and whether they ran successfully.

Skipped tasks and targets are shown in light grey text.

Selecting a tree node in the Build tab will show more information about that node in the Properties window.

MSBuild Binary Log File - Build tab - Properties window

Target Summary Tab

MSBuild Binary Log File - Target Summary tab

Targets are shown in the order they were run and can be sorted by clicking the column headers.

Task Summary Tab

MSBuild Binary Log File - Task Summary tab

Tasks are shown in the order they were run and can be sorted by clicking the column headers.

Project System Tools Installation

The Project System Tools extension is available from the Visual Studio for Mac extensions repository. To install the addin:

  • From the main menu, open the Extensions Manager dialog.
  • Select the Gallery tab.
  • Expand IDE extensions.
  • Select Project System Tools
  • Click the Refresh button if the extension is not visible.
  • Click Install… to install the extension.
  • Restart Visual Studio for Mac.

Links

NuGet Support in Visual Studio for Mac 8.3

Changes

  • NuGet 5.3 support
  • Managing NuGet packages for the solution
  • Show NuGet package updates for SDK style projects in the Solution window

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

NuGet 5.3 support

NuGet 5.3.0.6192 is now included with Visual Studio for Mac 8.3.

Managing NuGet Packages for the solution

Support for managing NuGet packages for the solution was originally available in a separate NuGet extensions addin. This feature has now been integrated into Visual Studio for Mac, along with some user interface changes, and is now available by default.

Manage NuGet Packages - Solution - Browse tab

The NuGet extensions addin is still available and provides a NuGet Powershell Console but it no longer includes a Manage NuGet Packages dialog.

The Manage NuGet Packages dialog contains four tabs:

  • Browse
    • Used to search for and install NuGet packages. This is equivalent to the old Add NuGet Packages dialog.
  • Installed
    • Shows the installed NuGet packages. NuGet packages can be uninstalled from this tab.
  • Updates
    • Shows NuGet packages that have new versions available.
  • Consolidate
    • Shows NuGet packages that have multiple versions installed in the solution. This is only available when managing NuGet packages for the solution.

The Add Packages dialog has been removed and replaced with the Manage NuGet Packages dialog since everything that was supported with the Add Packages dialog is available the new dialog.

To manage the NuGet packages for the solution the Manage NuGet Packages dialog can be opened in the following ways:

  • Right click the solution in the Solution window and select Manage NuGet Packages…
  • From the main menu select ProjectManage NuGet Packages…

The Manage NuGet Packages dialog title is different depending on whether the NuGet packages are being managed for the solution or for the project. When managing packages for the solution the dialog title will be Manage NuGet Packages – Solution.

Managing NuGet Packages for a single project

To manage NuGet packages for a single project the Manage NuGet Packages dialog can be opened in the following ways:

  • Right click the project in the Solution window and select Manage NuGet Packages…
    • This was added to make Visual Studio for Mac consistent with Visual Studio on Windows
  • Double click the Packages folder in the Solution window
  • Right click the Packages folder and select Manage NuGet Packages…
  • Double click the Dependencies folder in the Solution window.
    • In previous versions of Visual Studio for Mac this would not open the dialog
  • Right click the Depdendencies folder and select Manage NuGet Packages..
  • Double click the NuGet folder underneath the Dependencies folder
  • Right click the NuGet folder, underneath the Dependencies folder, and select Manage NuGet Packages…

When managing NuGet packages for a single project the dialog title shows the project name Manage NuGet Packages – ProjectName.

Manage NuGet Packages for Project

Installing NuGet Packages

The Browse tab in the Manage NuGet Packages can be used to search for and install NuGet packages into one or more projects. This tab is equivalent to the old Add NuGet Packages dialog.

The latest stable NuGet package version is now indicated by having (latest stable) appended on the right hand side of the dialog.

To install a NuGet package into multiple projects:

  • Right click the solution and select Manage NuGet Packages…
  • Search for a NuGet package
  • Click the Add Package button
  • In the Select Projects dialog that is opened, select the projects that you want the NuGet package to be installed, and click OK

Manage NuGet Packages - Select Projects dialog

Uninstalling NuGet Packages

The Installed tab in the Manage NuGet Packages can be used to uninstall NuGet packages from one or more projects.

Manage NuGet Packages - Installed tab

To uninstall a NuGet package:

  • Right click the solution and select Manage NuGet Packages…
  • Select the Installed tab
  • Select a NuGet package to uninstall
    • To uninstall multiple NuGet packages use the check boxes in the package list
  • Click the Uninstall Package button
  • In the Select Projects dialog that is opened, select the projects where the NuGet package should be removed, and click OK.

Updating NuGet Packages

The Updates tab shows the updated NuGet packages available to be installed.

Manage NuGet Packages - Updates tab

The Updates tab shows the Current Version of the NuGet package installed on the right hand side of the dialog. If multiple versions of the packages are installed across the solution, then this will display Multiple with an information icon where information about the projects and versions can be viewed in a tooltip.

Manage NuGet Packages - Updates tab -  Multiple versions installed

Manage NuGet Packages - Updates tab -  Multiple versions installed - tooltip

To update a NuGet package in multiple projects:

  • Right click the solution and select Manage NuGet Packages…
  • Select the Updates tab
  • Select a NuGet package to update
    • To update multiple NuGet packages use the check boxes in the packages list
  • Click the Update Package button
  • In the Select Projects dialog that is opened, select the projects where the NuGet package should be updated, and click OK.

Consolidating NuGet Packages

If there are different versions of a NuGet package installed in the solution the Consolidate tab will show this and allow the packages to be consolidated to a particular version.

Manage NuGet Packages - Consolidate tab

When a NuGet package is selected, the right hand side of the dialog shows all the projects in the solution. The project will be checked if it has the selected package installed. The package version used by the project is also shown. Projects that have a package to consolidate are shown first in the list.

Note that the Consolidate tab is only displayed if NuGet packages are being managed for the solution.

By default the Consolidate tab will select the latest version available from the current NuGet package source. This may be different from the latest version installed in the projects.

To Consolidate a NuGet package:

  • Right click the solution and select Manage NuGet Packages…
  • Select the Consolidate tab
  • Select the NuGet package you want to consolidate.
    • Use the check box next to the NuGet package if you want to consolidate multiple NuGet packages at the same time
  • Check or uncheck the projects in the projects list.
    • By default projects that contain the selected NuGet package will be checked
  • Click the Consolidate Package button.

Show NuGet package updates for SDK style projects in the Solution window

NuGet package updates are now shown in the Solution window for SDK style projects.

SDK style project - package updates - solution window

If an updated package is available this information will now be shown on the Dependencies folder, the NuGet folder, and the top level package in the Solution window.

Previously NuGet package updates were only displayed for projects that used a packages.config file or for non-SDK style projects that used PackageReferences.

Instead of showing the updated NuGet package version text, next to the installed version in the solution window, an update icon is displayed with the version information available in a tooltip. This prevents the version information taking up a lot of space to the right, which can happen for long version numbers.

SDK style project - package update version tooltip - solution window

The Update menu, when right clicking a NuGet package, now shows the version for the update. Otherwise the Update menu is displayed.

SDK style project - update menu item - solution window

If there is an update and a NuGet warning only the warning icon will be displayed with the warning message available in the tooltip. The update information will only be available in the right click context menu for the NuGet package in this case.

Package versions are now displayed in solution window for non-SDK style projects.

Non-SDK style project - package updates - solution window

SDK style projects always displayed the package version in the Solution window but non-SDK style projects did not. To make these consistent the NuGet package version is now shown in the Solution window for all project types.

Previously for non-SDK style projects the package version was shown as a menu item when right clicking a NuGet package. This has been removed since the package version is now displayed next to the package id in the Solution window.

Bug Fixes

Fixed text colour when row selected in Manage NuGet Packages dialog

When a package was checked in the Add NuGet Packages dialog any row that was selected would display black text instead of white text. This was hard to read with the blue background colour used for the selected row. The wrong text colour was being set when a package was checked. This has been fixed in the Manage NuGet Packages dialog.

NuGet Support in Visual Studio for Mac 8.2

Changes

  • NuGet 5.1 support
  • Support partial installs into multi-target framework projects
  • Fixed no network error displayed in Add Packages dialog
  • Fixed restoring too many projects when target framework changed
  • Fixed adding non-sdk style project triggering NuGet restore multiple times
  • Fixed restore menu incorrectly disabled

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

NuGet 5.1 support

NuGet 5.1.0.6013 is now included with Visual Studio for Mac 8.2.

Support partial installs into multi-target framework projects

A NuGet package being installed into a multi-target framework project may not support all frameworks. When this happens the PackageReference will now be added with a condition so the NuGet package is not used for frameworks that are not supported.

1
2
3
4
5
6
7
8
9
10
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>net472;netstandard1.2</TargetFrameworks>
  </PropertyGroup>

  <ItemGroup Condition="'$(TargetFramework)' == 'net472'">
    <PackageReference Include="EntityFramework" Version="6.2.0" />
  </ItemGroup>
</Project>

Bug Fixes

Fixed no network error displayed in Add Packages dialog

Networking errors were not being reported in the Add Packages dialog resulting in no information being available explaining why there were no search results.

Visual Studio for Mac uses Xamarin.Mac’s NSUrlSessionHandler for HTTP requests and the NSUrlSessionHandler reports errors using curly braces. For example:

1
2
[nuget.org] The Internet connection appears to be offline.
  Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={NSUnderlyingError=0x7fce42892a80 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, NSErrorFailingURLStringKey=https://api-v2v3search-1.nuget.org/query?q=&skip=0&take=26&prerelease=false&supportedFramework=Xamarin.iOS,Version=v1.0&semVerLevel=2.0.0, NSErrorFailingURLKey=https://api-v2v3search-1.nuget.org/query?q=&skip=0&take=26&prerelease=false&supportedFramework=Xamarin.iOS,Version=v1.0&semVerLevel=2.0.0, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=50, NSLocalizedDescription=The Internet connection appears to be offline.}

This text was then being passed to string.Format in the Add Packages dialog and was causing a FormatException. The error would then not be displayed in the Add Packages dialog. The text now has the curly braces escaped to prevent the FormatException.

Fixed restoring too many projects when target framework changed

When the target framework was changed in a SDK style project all SDK style projects in the solution were restored. Now only the project and projects that depend on it are restored.

Fixed adding non-sdk style project triggering NuGet restore multiple times

Adding a new non-sdk style project to a solution could cause a NuGet restore to run multiple times.

The problem was that the SDK style projects, such as those that target Xamarin.Mac, may change their target framework on re-evaluation. This was causing Visual Studio for Mac to run a restore for all SDK style projects in the solution, multiple times. To avoid this the target framework changes during re-evaluation are ignored.

Fixed restore menu incorrectly disabled

In the Solution window on right clicking a solution, or the packages folder, the restore menu was incorrectly disabled when an SDK style project targeted .NET Framework or when the project had its RestoreProjectStyle set to PackageReference and had no PackageReferences.

LibMan support in Visual Studio for Mac

The Library Manager addin provides Microsoft Library Manager (LibMan) support for Visual Studio for Mac. LibMan provides a way to install third-party client-side JavaScript libraries for ASP.NET Core and ASP.NET projects.

Features

  • Add Client-Side Library dialog
  • Restore client-side libraries
  • Deleting client-side libraries
  • Automatic client-side library restore on saving libman.json file

Full text editor support is not currently available. The following text editor quick actions are not supported:

  • Uninstall a client-side library
  • Check for client-side library updates

Supports

  • Visual Studio Mac 8.1 or later.
  • ASP.NET Core and ASP.NET projects

Add Client-Side Library Dialog

To open the Add Client-Side Library dialog, right click the project, or a folder, and select Add – Client-Side Library.

Add - Client-Side Library menu

Add Client-Side Library dialog

The library provider can be selected from the Provider list.

Typing in the Library text field will search the library provider and show a list of matching libraries.

Add Client-Side Library dialog completion list

Pressing tab or return will insert the selected library from the completion list into the Library text field.

You can then choose to include all the client-side library files or a selection of those files.

Add Client-Side Library dialog select files

The Target Location indicates where the client-side library files will be installed.

Clicking the Install button will create a libman.json file and install the client-side library into your project.

jQuery installed into project

More detailed information about the client-side library installation is available by clicking the status bar or by selecting View – Pads – Library Manager Output.

Library Manager Output window

Adding a libman.json file

To add a libman.json file without using the Add Client-Side Library dialog, right click the ASP.NET project and select Manage Client-Side Libraries.

Manage Client-Side Libraries menu

This will create a libman.json file and open it in the text editor.

libman.json file in text editor

Restoring Client-Side Libraries

To restore the client-side libraries you can right click the libman.json file in the Solution window and select Restore Client-Side Libraries.

Restore Client-Side Libraries menu

Information about the restore operation is available from the Library Manager Output window.

Alternatively saving the libman.json file in the text editor will run a restore.

Restore errors are displayed in the Errors window and in the libman.json file if it is open in the text editor.

LibMan restore error

Deleting Client-Side Libraries

To remove the client-side libraries you can right click the libman.json file in the Solution window and select Clean Client-Side Libraries.

Clean Client-Side Libraries menu

This will delete the client-side libraries from the project.

Library Manager Addin Installation

The Library Manager addin is available from the Visual Studio for Mac extensions repository. To install the addin:

  • From the main menu, open the Extensions Manager dialog.
  • Select the Gallery tab.
  • Expand IDE extensions.
  • Select the Library Manager addin
  • Click the Refresh button if the addin is not visible.
  • Click Install… to install the addin.
  • Restart Visual Studio for Mac.

Links

NuGet Support in Visual Studio for Mac 8.1

Changes

  • NuGet 5.0 support
  • Fixed PackageReference metadata not added for development dependencies
  • Fixed DotNetCliToolReferences not being restored
  • Fixed Multiplatform Library build error with Android projects

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

NuGet 5.0 support

NuGet 5.0.2.5988 is now included with Visual Studio for Mac 8.1.

Bug Fixes

Fixed PackageReference metadata not added for development dependencies

Installing a NuGet package that is a development dependency, such as GitInfo, would not add the PrivateAssets nor the IncludeAssets metadata to the PackageReference. This is now supported and mirrors the behaviour of ‘dotnet add package’ and Visual Studio on Windows.

Fixed DotNetCliToolReferences not being restored

DotNetCliToolReferences are available in the package dependency graph but are treated as separate projects in this graph. Since these did not map to an existing project in the solution they were not added to the full dependency graph which resulted in these tools not being restored.

DotNetCliToolReferences are only restored when the entire solution is restored. Restoring a single project only restores the project itself not the dotnet cli tool project referenced by the project.

MSBuild supports restoring DotNetCliToolReferences in any project type that uses PackageReferences so Visual Studio for Mac also supports this.

Fixed Multiplatform Library build error with Android projects

When generating a Portable Class Library (PCL) assembly from the intersection of project assemblies the ApiIntersect build task would throw an exception since it could not resolve the Mono.Android assembly. This problem has been fixed in a more recent NuGet.Build.Packaging where the failure to resolve has been converted to a warning.

1
2
3
4
5
6
7
8
9
10
System.Exception: Could not resolve Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065
    at ApiIntersect.FrameworkAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x0001b] in <aac3e0d5bcd4473a96e385115da49b96>:0
    at ApiIntersect.FrameworkAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00000] in <aac3e0d5bcd4473a96e385115da49b96>:0
    at ICSharpCode.Decompiler.Ast.Transforms.IntroduceUsingDeclarations.Run (ICSharpCode.NRefactory.CSharp.AstNode compilationUnit) [0x00142] in <37b5ad8a7a94479fbc5b574a8fc6281a>:0
    at ICSharpCode.Decompiler.Ast.Transforms.TransformationPipeline.RunTransformationsUntil (ICSharpCode.NRefactory.CSharp.AstNode node, System.Predicate`1[T] abortCondition, ICSharpCode.Decompiler.DecompilerContext context) [0x0002c] in <37b5ad8a7a94479fbc5b574a8fc6281a>:0
    at ICSharpCode.Decompiler.Ast.AstBuilder.RunTransformations (System.Predicate`1[T] transformAbortCondition) [0x00000] in <37b5ad8a7a94479fbc5b574a8fc6281a>:0
    at ICSharpCode.Decompiler.Ast.AstBuilder.RunTransformations () [0x00000] in <37b5ad8a7a94479fbc5b574a8fc6281a>:0
    at ApiIntersect.MainClass.DumpTypes (System.Collections.Generic.List`1[T] types, System.String baseDir) [0x000a7] in <aac3e0d5bcd4473a96e385115da49b96>:0
    at ApiIntersect.MainClass.Process (System.Collections.Generic.List`1[T] intersections, System.Collections.Generic.List`1[T] exclusions, Mono.Cecil.ReaderParameters readerParameters, System.String outputPath) [0x00319] in <aac3e0d5bcd4473a96e385115da49b96>:0
    at ApiIntersect.MainClass.Main (System.String[] args) [0x0039f] in <aac3e0d5bcd4473a96e385115da49b96>:0

An updated NuGet.Build.Packaging has not been published to nuget.org so only new projects created with Visual Studio for Mac will get the NuGet package containing the fix.