The NuGet extensions addin now includes a PowerShell Core based NuGet Package Manager console for Visual Studio for Mac 8.0.
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.
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
- 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:
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.
Entity Framework Core Support
The PowerShell commands provided by the Microsoft.EntityFrameworkCore.Tools NuGet package are supported in .NET Core projects.
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.
Pressing tab in the console window will try to auto-complete the command being typed in.
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.
Clicking this button will attempt to stop the PowerShell command being run.
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.
Clicking this cog icon will open the NuGet Package Sources configuration page which is also available from Preferences – NuGet – Sources.
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.