Matt Ward

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.

NuGet PowerShell Core Console in Visual Studio for Mac 8.0

The NuGet extensions addin now includes a PowerShell Core based NuGet Package Manager console for Visual Studio for Mac 8.0.

NuGet Package Manager Console window

A NuGet PowerShell console has been available with the NuGet extensions addin since Xamarin Studio 5.0. Previously it used Pash, a cross-platform, open source reimplementation of PowerShell. Pash is no longer being actively developer on after Microsoft released PowerShell Core. The PowerShell support in Pash was incomplete, so whilst the NuGet commands, such as Install-Package, were supported, more complicated commands, such as those provided by Entity Framework Core, were not supported. Moving to PowerShell Core provides full PowerShell support, and with a partial implementation of the Visual Studio EnvDTE API, Entity Framework Core commands are now supported.

The NuGet extensions addin runs a .NET Core console application that hosts PowerShell Core. Communication between the addin running in Visual Studio for Mac and the console application is through the StreamJsonRpc library.

New Features

The following lists the new features compared with the Pash based PowerShell console.

  • PowerShell Core based NuGet Package Manager Console
    • Full PowerShell support
    • Get-Help now supported
  • Support for Entity Framework Core NuGet commands
  • Tab completion
  • Support for stopping the executing command
  • Opening the NuGet package source configuration page from the console

Limitations

  • Visual Studio EnvDTE API implementation is incomplete

The Visual Studio EnvDTE API is partially implemented. Whilst Entity Framework Core is supported other PowerShell scripts included with NuGet packages may not work.

  • Password protected NuGet package sources not supported in the following PowerShell commands:

    • Find-Package
    • Get-Package

Note that the other NuGet PowerShell commands are supported.

The NuGet extensions addin will not send usernames and passwords to the PowerShell Core host console application. .NET Core also does not support decrypting passwords stored in the NuGet.Config file.

The Find-Package and Get-Package commands all run completely within PowerShell hosted in the .NET Core console application.

The other commands work since they run partially within Visual for Mac where actions involving password protected NuGet package sources are supported.

  • Requires .NET Core 2.1 SDK to be installed

Opening the NuGet Package Manager Console window

From the View menu, select Pads, then select NuGet Package Manager Console.

View - Pages - NuGet Package Manager Console menu

 Entity Framework Core Support

The PowerShell commands provided by the Microsoft.EntityFrameworkCore.Tools NuGet package are supported in .NET Core projects.

  • Add-Migration
  • Drop-Database
  • Get-DbContext
  • Remove-Migration
  • Scaffold-DbContext
  • Script-Migration
  • Update-Database

Package Manager Console - Entity Framework Core Add-Migration and Update-Database commands

Note that the Entity Framework Core commands are not currently supported in projects that target the .NET Framework. This is because the PowerShell commands attempt to directly run ef.exe that is included in the NuGet package instead of using the .NET Core ef.dll which is used with projects that target .NET Core.

Tab Completion

Pressing tab in the console window will try to auto-complete the command being typed in.

Tab completion - Install-Package Newtonsoft.Json

Tab completion - Install-Package Newtonsoft.Json -Version

If there is only one match on pressing tab then the text will be inserted.

If there are multiple possible matches then a window will be displayed allowing an item to be selected by pressing Tab, Enter or Return. Typing with this completion list window open will filter the items in the list.

Stopping the PowerShell command being run

When a PowerShell command is being run the Stop button is enabled. The Stop button is the last button on the top right of the NuGet Package Console window.

Package Manager Console stop button

Clicking this button will attempt to stop the PowerShell command being run.

Package Manager Console pipeline stopped

Opening the NuGet Package Console configuration page

At the top of the NuGet Package Console window there is a cog icon after the list of package sources.

Package Manager Console configure sources cog icon

Clicking this cog icon will open the NuGet Package Sources configuration page which is also available from Preferences – NuGet – Sources.

Installation

The NuGet extensions 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 NuGet Package Management Extensions 0.18 or later.
  • Click the Refresh button if the addin is not visible.
  • Click Install… to install the addin.
  • Restart Visual Studio for Mac.

NuGet Support in Visual Studio for Mac 8.0

Changes

  • Fixed build action not available after installing package into a PackageReference project
  • Fixed NuGet extension api install events not raised for PackageReference projects

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

Bug Fixes

Fixed build action not available on installing package into a PackageReference project

After installing the Xamarin.GooglePlayServices.Basement NuGet package, into a project that used PackageReferences, the GoogleServicesJson build action, defined by this NuGet package, was not available in the list of build actions when you right clicked a file in the Solution window. The build action was available after the solution was closed and re-opened.

Installing a NuGet package into a project that used PackageReferences would not re-evaluate the project’s MSBuild information. This resulted in any custom AvailableItemNames not being available to be used as a build action in the Solution window. The build actions for a project were cached so these are now cleared to ensure the latest items are available after an re-evaluation.

Fixed NuGet extension api install events not raised for PackageReference projects

The NuGet extension API has a PackageReferenceAdded event and a PackageReferenceRemoved. These were being raised if a project had a packages.config file but not if the project used PackageReferences.

NuGet Support in Visual Studio for Mac 7.8

Changes

  • NuGet package diagnostics displayed in Solution window
  • Support restoring multi-target framework projects
  • Display summary of NuGet restore errors in Package Console
  • Fixed wrong version of Microsoft.AspNetCore.App being restored
  • Fixed Paket restore not working with SDK style projects
  • Fixed NuGet restore ignoring build targets

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

NuGet package diagnostics displayed in Solution window

NuGet package diagnostic warnings are now shown in the Solution window.

NuGet package diagnostic warnings in Solution Window

The diagnostic warnings are shown underneath the NuGet package with a warning icon. Hovering over the warning icon will show a tooltip.

NuGet package diagnostic warning tooltip in Solution Window

Support restoring multi-target framework projects

Projects that have multiple target frameworks now have all frameworks restored.

Multi-target framework project restored in Solution window

Previously only the first target framework would be restored.

Conditional PackageReferences defined in the project file are also now respected when restoring the project. Previously the conditions on the PackageReferences would be ignored.

Conditional PackageReferences restored in Solution window

Visual Studio for Mac now uses the GenerateRestoreGraphFile MSBuild target to determine package dependencies. Previously this information was obtained from the project information held in memory. This fixes several NuGet restore bugs in Visual Studio for Mac.

Display summary of NuGet restore errors in Package Console

Creating an xUnit .NET Core test project named ‘xunit’ fails to restore since there is a package reference cycle between the project and the xunit NuGet package. Whilst this reference cycle is reported it is hidden in the Package Console output and all you would see was a message indicating that the restore had failed. Now the error information is shown at the end of the Package Console as a summary of the failures to make it easier to see the problem.

Now for the xunit project you will see the following at the end of the Package Console output:

Cycle detected.
  xunit -> xunit (>= 2.3.1).
Restore failed.

Bug Fixes

Fixed wrong version of Microsoft.AspNetCore.App being restored

With an ASP.NET Core 2.1 project, that had included a PackageReference for Microsoft.AspNetCore.App version 2.1.5, Visual Studio for Mac would incorrectly restore Microsoft.AspNetCore.App version 2.1.1.

Using the GenerateRestoreGraphFile MSBuild target to determine package reference information when restoring has fixed this problem.

Fixed Paket restore not working with SDK style projects

When Paket is used with an SDK style project it injects PackageReferences via the PaketRestore target from the Paket.Restore.targets file. Visual Studio for Mac was not using MSBuild to get the package reference information so PackageReferences defined by Paket were not being restored or made available.

Fixed NuGet restore ignoring build targets

OrchardCore would fail to restore when opened in Visual Studio for Mac. OrchardCore defines the PackageReference versions in a separate MSBuild .props file and has a custom MSBuild target to define these versions. This custom MSBuild target is now supported since Visual Studio for Mac uses the GenerateRestoreGraphFile MSBuild target to determine package references when restoring.

Task Runner Explorer in Visual Studio for Mac

The Task Runner Explorer addin provides a Task Runner Explorer window, similar to the one in Visual Studio on Windows, which can be used to run tasks with Cake, Gulp, Grunt, NPM and TypeScript.

Task Runner Explorer Window

Features

  • Task Runner Explorer Window
    • View tasks
    • Run tasks
    • View task output
    • Run and cancel long running tasks, such as tcs watch
    • Configure tasks to run when specific IDE events occur
      • Before Build
      • After Build
      • Clean
      • Project Opened
      • Solution Opened
  • Task Runners
    • Cake
    • Gulp
    • Grunt
    • NPM
    • TypeScript

Supports

  • Visual Studio Mac 7.5 or later.

Task Runner Explorer

To open the Task Runner Explorer window, from the View menu select Pads, then select Task Runner Explorer.

View Task Runner Explorer menu

The Task Runner Explorer will look for files supported by a task runner in the solution directory and the project directory. It will also look at all files that have been added to a project or that have been added to a solution folder.

Task Runner Explorer TypeScript and NPM tasks

The top left of the Task Runner Explorer shows a list of projects or the solution that have tasks available. This can be used to filter the tasks shown in the Task Runner Explorer window.

Currently changes made to tasks will not be detected automatically. To refresh the task information you can click the Refresh button available at the top left of the Task Runner Explorer window.

Running a Task

To run a task you can double click it or right click and select Run.

Task Runner Explorer Run menu

Output from the task is shown on the right hand side of the Task Runner Explorer window.

NPM update running

NPM update completed

A long running task, such as tcs watch, will run until the solution is closed, or the Stop button, available on the right hand side of the Task Runner Explorer window, is clicked.

Binding Tasks to IDE Events

Tasks can be configured to run when the following IDE events occur:

  • After Build
  • Before Build
  • Clean
  • Project or Solution Opened

If the task runner file is in a project directory then the build and clean events are associated with the project. If the task runner file is in a solution directory then the build events are associated with the solution.

To configure a task, right click it, select Bindings and then select the event.

Task Runner Explorer Bindings menu

The binding will be displayed in the Bindings tab and will also be shown as checked when the context menu for the task is opened.

Task Runner Explorer Before Build binding added

To remove the binding you can right click the task, select Bindings and select the event again to uncheck it. Alternatively you can right click it in the Bindings tab and select Remove.

The order in which the tasks are run for a particular IDE event can be changed by right clicking the binding in the Bindings tab and selecting Move Up or Move Down.

Task Runner Explorer binding Move Up and Down menus

The binding information is typically saved in a file in the same directory as the corresponding task runner file, however this depends on how the task runner is implemented.

Disabling Automatic Running of Tasks

In preferences there is a Task Runner Explorer section which shows a check box that can be used to enable or disable the automatic running of tasks on opening a project or solution, and when building or cleaning.

Preferences - Automatically run tasks option

Cake Task Runner

The Cake task runner supports running tasks defined in a build.cake file.

Cake Task Runner

This is based on the Cake Task Runner for Visual Studio.

Gulp Task Runner

The Gulp task runner supports running tasks defined in a gulpfile.js file.

Gulp Task Runner

Gulp needs to be installed separately.

Grunt Task Runner

The Grunt task runner supports running tasks defined in a Gruntfile.js file.

Grunt Task Runner

Grunt needs to be installed separately.

NPM Task Runner

The NPM task runner supports running tasks defined in a package.json file.

NPM task runner

The NPM task runner is a port of Mads Kristensen’s NPM Task Runner.

The NPM task runner supports running with the verbose NPM option defined. If a task is selected then a button will be displayed on the left hand side of the Task Runner Explorer window. If this is selected then npm will be passed the -d argument when it is run.

NPM task runner Verbose button

NPM needs to be installed separately.

TypeScript Task Runner

The TypeScript task runner supports running tcs build and tcs watch if a tsconfig.json file is found.

TypeScript task runner

TypeScript tcs watch output

The TypeScript task runner will try to use tsc that is distributed with the Web Tools extension that is included in Visual Studio for Mac. If the Web Tools extension is not installed then the task runner will fall back to running tsc directly.

Installation

There are two addins to be installed:

The Task Runner is the main addin. This will be used by other task runner addins and provides the main task runner API and services.

The Task Runners Bundle addin contains the Cake, Gulp, Grunt, NPM and TypeScript task runners. These are currently included together as a single addin instead of being distributed separately.

Download both of the above .mpack files. Install the Task Runner addin first since the Task Runners Bundle addin depends on it. To install an addin’s .mpack file, open the Extensions Manager by selecting Extensions… from the main menu. Click the Install from file button. Select the .mpack file and then click the Open button. After installing both the addins restart Visual Studio for Mac.

These addins are not currently available from the main Visual Studio for Mac extensions server.

Source Code