Repository Management with Nexus
24.6. .NET Integration
The NuGet project provides a package and dependency management solution for .NET developers. It is integrated directly into Visual Studio and makes it easy to add, remove and update libraries and tools in Visual Studio and on the command line for projects that use the .NET Framework. Nexus can act as a proxy between your developer’s Visual Studio instances and the public NuGet Gallery.
When you configure Nexus Professional to act as a proxy for NuGet Gallery you gain a more reliable build that depends on locally cached copies of the components you depend on. If NuGet Gallery has availability problems, your developers can continue to be productive. Caching components locally will also result in a faster response for developers downloading .NET dependencies.
In this example, you will…
- Configure your Visual Studio instance to download NuGet packages from your local Nexus server
- Consume components from NuGet Gallery via Nexus
Let’s get started
Your Nexus Professional Trial instance has been preconfigured with the following NuGet repositories:
- A Proxy Repository for NuGet Gallery
- A Hosted Repository for your internal .NET components
- A Group which combines both the NuGet Gallery Proxy and the Hosted NuGet Repository
To consume .NET components from Nexus Professional you will need to install the NuGet feature in Visual Studio as referenced in Section 24.1.6, “Microsoft Visual Studio And NuGet” and configure it appropriately:
- Open Nexus Professional, click on Repositories in the left-hand navigation menu and locate the NuGet Group repository group. This is the aggregating group from which Visual Studio should download packages. Click on this repository group in the list of repositories.
- Select the NuGet tab below the list of repositories with the NuGet Group selected and copy the URL in the Package Source field to your clipboard. The value should be http://localhost:8081/nexus/service/local/nuget/nuget-group/
- Now in Visual Studio, right-click on a Visual Studio project and select Add Library Reference
- In the Add Library Package Reference click on the Settings button in the lower left-hand corner.
- This will bring up an Options button. Remove the initial NuGet repository location and replace it with a reference to your Nexus instance. Clicking Add to add the reference to your Nexus Instance.
- Click on OK to return to the Add Library Package Reference dialog.
- Select the Online item in the left-hand side of the dialog, at this point Visual Studio will interrogate your Nexus instance for a list of NuGet packages.
- You can now locate the package you need and install it.
- To verify that the NuGet package components are being served from Nexus you can return to the Nexus web interface and browse the local storage of your NuGet proxy repository.
Watch this video of the steps being performed in Visual Studio.
The above instructions were created using Visual Studio 10 Web Developer Express. Your configuration steps may vary if you are using a different version of Visual Studio.
Nexus Professional can improve collaboration and control while speeding .NET development. NuGet defines a packaging standard that organizations can use to share code.
If your organization needs to share .NET components you can publish these components to a hosted NuGet repository on Nexus Professional. This makes it easy for projects within your organization to start publishing and consuming NuGet packages using Nexus as a central hub for collaboration.
Once NuGet packages are published to your Nexus Professional instance they are automatically be added to the NuGet repository group and your internal packages will be as easy to consume as packages from NuGet Gallery.
In this example, you will…
- Publish NuGet packages to a Hosted NuGet repository
- Distribute custom .NET components using Nexus Professional
Let’s get started: