Changes
- NuGet 5.3 support
- Managing NuGet packages for the solution
- Show NuGet package updates for SDK style projects in the Solution window
It would be very useful to have such a powerful nuget package manager as the Visual Studio manager will be very productive. The text was updated successfully, but these errors were encountered. Package Manager Console Commands for Migrations Migration commands in Entity Framework Core can be executed using the Package Manager Console in Visual Studio. Open the Package Manager Console from menu Tools - NuGet Package Manger - Package Manager Console in Visual Studio to execute the following commands. @SergeAdneom I do, but I don't have that machine anymore, so I've went to test on my current machine and both of the key successions work, because Package Manager Console is available on both menus 'View Other windows PMC' and 'Tools NuGet Package Manager. 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. Is there anyway to open NuGet Package Manager console outside Visual Studio? My objective is to run some migrations, which I created using EntityFramework.Migrations. Basically I want to run Update-Database –Verbose command in an environment which does not have visual studio, but does have PowerShell 2.0 and NuGet command line tool.
More information on all the new features and changes in Visual Studio for Mac 8.3can be found in the release notes.
NuGet 5.3 support
NuGet 5.3.0.6192 is nowincluded 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 separateNuGet extensions addin. This feature has nowbeen integrated into Visual Studio for Mac, along with some user interface changes, and is now available bydefault.
The NuGet extensions addin is still available and provides aNuGet 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 managingNuGet 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 forthe 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 Project – Manage NuGet Packages…
The Manage NuGet Packages dialog title is different depending on whether the NuGet packagesare being managed for the solution or for the project. When managing packages for the solutionthe 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 openedin 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 nameManage NuGet Packages – ProjectName.
![Package Package](http://www.macoratti.net/20/01/ang_kitdev13.jpg)
Installing NuGet Packages
The Browse tab in the Manage NuGet Packages can be used to search for and install NuGet packagesinto one or more projects. This tab is equivalent to the old Add NuGet Packages dialog.
The latest stable NuGet package version is now indicated byhaving (latest stable) appended on the right handside 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
Uninstalling NuGet Packages
The Installed tab in the Manage NuGet Packages can be used to uninstallNuGet packages from one or more projects.
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.
The Updates tab shows the Current Version of the NuGet package installed on the right hand side of the dialog. Ifmultiple versions of the packages are installed across the solution, then this willdisplay Multiple with an information icon where information about theprojects and versions can be viewed in a 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.
Vs Package Manager Console
Consolidating NuGet Packages
If there are different versions of a NuGet package installed in the solution theConsolidate tab will show this and allow the packages to be consolidated to a particular version.
When a NuGet package is selected, the right hand side of the dialog showsall the projects in the solution. The project will be checked if it has the selectedpackage 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 beingmanaged 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 styleprojects.
If an updated package is available this information will now be shownon the Dependencies folder, the NuGet folder, and the top levelpackage in the Solution window.
Previously NuGet package updates were only displayed for projectsthat used a packages.config file or for non-SDK style projectsthat used PackageReferences.
Instead of showing the updated NuGet package version text, next to the installed versionin the solution window, an update iconis displayed with the version information available in a tooltip. This preventsthe version information taking up a lot of space to the right, which canhappen for long version numbers.
The Update menu, when right clicking a NuGet package, now shows theversion for the update. Otherwisethe Update menu is displayed.
If there is an update and a NuGet warning only the warning iconwill be displayed with the warning message available in the tooltip.The update information will only be available in the right clickcontext menu for the NuGet package in this case.
Package versions are now displayed in solution window for non-SDK style projects.
Nuget Install Nupkg Locally
SDK style projects always displayed the package version in the Solutionwindow but non-SDK style projects did not. To make these consistent the NuGetpackage version is now shown in the Solution window for all project types.
Previously for non-SDK style projects the package version was shownas a menu item when right clicking a NuGet package. This has been removedsince the package version is now displayed next to the package id in theSolution 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 anyrow that was selected would display black text instead of white text. This was hardto read with the blue background colour used for the selected row. The wrong text colour was being set when a package waschecked. This has been fixed in the Manage NuGet Packages dialog.
-->NuGet packages contain reusable code that other developers make available to you for use in your projects. See What is NuGet? for background. Packages are installed into a Visual Studio for Mac project using the NuGet Package Manager. This article demonstrates the process using the popular Newtonsoft.Json package and a .NET Core console project. The same process applies to any other Xamarin or .NET Core project.
Once installed, refer to the package in code with using
where is specific to the package you're using. Once the reference is made, you can call the package through its API.
Tip
Start with nuget.org: Browsing nuget.org is how .NET developers typically find components they can reuse in their own applications. You can search nuget.org directly or find and install packages within Visual Studio as shown in this article. For general information, see Find and evaluate NuGet packages.
Prerequisites
- Visual Studio 2019 for Mac.
You can install the 2019 Community edition for free from visualstudio.com or use the Professional or Enterprise editions.
If you're using Visual Studio on Windows, see Install and use a package in Visual Studio (Windows Only).
Create a project
NuGet packages can be installed into any .NET project, provided that the package supports the same target framework as the project.
For this walkthrough, use a simple .NET Core Console app. Create a project in Visual Studio for Mac using File > New Solution..., select the .NET Core > App > Console Application template. Click Next. Accept the default values for Target Framework when prompted.
Visual Studio creates the project, which opens in Solution Explorer.
Add the Newtonsoft.Json NuGet package
To install the package, you use the NuGet Package Manager. When you install a package, NuGet records the dependency in either your project file or a packages.config
file (depending on the project format). For more information, see Package consumption overview and workflow.
NuGet Package Manager
In Solution Explorer, right-click Dependencies and choose Add Packages....
Choose 'nuget.org' as the Package source in the top left corner of the dialog, and search for Newtonsoft.Json, select that package in the list, and select Add Packages...:
If you want more information on the NuGet Package Manager, see Install and manage packages using Visual Studio for Mac.
Use the Newtonsoft.Json API in the app
With the Newtonsoft.Json package in the project, you can call its JsonConvert.SerializeObject
method to convert an object to a human-readable string.
Open the
Program.cs
file (located in the Solution Pad) and replace the file contents with the following code:Build and run the app by selecting Run > Start Debugging:
Once the app runs, you'll see the serialized JSON output appear in the console:
Next steps
Congratulations on installing and using your first NuGet package!
Package Manager Console Install Package
To explore more that NuGet has to offer, select the links below.