Repository Management with Nexus


25.6. .NET Integration

25.6.1. Consume .NET Components from NuGet Gallery

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 Pro to act as a proxy for NuGet Gallery you gain a more reliable build that depends on locally cached copies of the components on which you depend. 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 Pro 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

Figure 25.8. NuGet Repositories in Repository List Accessed Using the List Filter Feature

To consume .NET components from Nexus you will need to install the NuGet feature in Visual Studio as referenced in Section 25.1.6, “Microsoft Visual Studio and NuGet” and configure it appropriately:

  1. Open Nexus Pro, 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.
  2. 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/.
  3. Now in Visual Studio, right-click on a Visual Studio project and select Add Library Reference.
  4. In the Add Library Package Reference, click on the Settings button in the lower left-hand corner.
  5. 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.
  6. Click OK to return to the Add Library Package Reference dialog.
  7. 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.
  8. You can now locate the package you need and install it.
  9. 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.

25.6.2. Publish and Share .NET Components with NuGet

Nexus can improve collaboration and control, while increasing the speed of .NET development. NuGet defines a packaging standard that organizations can use to share components.

If your organization needs to share .NET components, you can publish these components to a hosted NuGet repository on Nexus. 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 instance they are automatically added to the NuGet repository group, making your internal packages 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.

Let’s get started:

  1. Follow the example from Section 25.6, “.NET Integration” to set up proxying of NuGet packages from Nexus.
  2. Activate the NuGet API Security Realm → Read more…
  3. Create a NuGet Package in Visual Studio. Creating a package for deployment can be done with the pack command of the nuget command line tool or within Visual Studio. Detailed documentation can be found on the NuGet website.
  4. Publish a NuGet Package to Nexus → Read more…

25.6.3. Security

Integration with Enterprise LDAP Solutions

Organizations with large, distributed development teams often have a variety of authentication mechanisms, from multiple LDAP servers with multiple User and Group mappings, to companies with development teams that have been merged during an acquisition. Nexus Pro’s Enterprise LDAP support was designed to meet the most complex security requirements and give Nexus administrators the power and flexibility to adapt to any situation.

Nexus Pro offers LDAP support features for enterprise LDAP deployments including detailed configuration of cache parameters, support for multiple LDAP servers and backup mirrors, the ability to test user logins, support for common user/group mapping templates, and the ability to support more than one schema across multiple servers.

Let’s get started

Read more about configuring Enterprise LDAP to learn about the following:

  • Configuring LDAP caching and timeout.
  • Configuring and testing LDAP failover.
  • Using LDAP user and group mapping templates for Active Directory, POSIX with dynamic or static groups or generic LDAP configuration.

With Enterprise LDAP support in Nexus Pro, you can do the following:

  • Cache LDAP authentication information.
  • Use multiple LDAP servers, each with different User and Group mappings.
  • Use LDAP servers with multiple backup instances and test the ability of Nexus to failover in the case of an outage.
  • Augment the roles from LDAP with Nexus specific privileges.

Integration with Atlassian Crowd

If your organization uses Atlassian Crowd, Nexus Pro can delegate authentication and access control to a Crowd server by mapping Crowd groups to Nexus roles.

Let’s get started

  1. Configure the Crowd Plugin → Read more…
  2. Map Crowd Groups to Nexus Roles → Read more…
  3. Add the Crowd Authentication Realm → Read more…

25.6.4. Enterprise Deployments

Scaling Nexus Deployments for Distributed Development

Avoid downtime by deploying Nexus in a highly available configuration! With the Nexus Pro feature Smart Proxy, two distributed teams can work with local instances of Nexus that will inform each other of new components as they are published. Smart Proxy is an enhanced proxy setup with push notifications and potential prefetching of components. It allows you to keep proxy repositories on multiple Nexus servers in sync without sacrificing performance.

A team in New York can use a Nexus instance in New York and a team in Sydney can use an instance in Australia. If a component has been deployed, deleted, or changed, the source repository notifies the proxy. Both teams are assured that Nexus will never serve stale content. This simple mechanism makes it possible to build complex distributed networks of Nexus instances relying on this publish/subscribe approach.

In this example, you will…

  • Setup two instances of Nexus Pro.
  • Configure one instance to proxy the hosted instances of the other instance.
  • Configure the proxying instance to subscribe to Smart Proxy events.

Let’s get started

  1. Enable Smart Proxy publishing → Read more…
  2. Establish trust between Nexus instances → Read more…
  3. Configure Smart Proxy for specific repositories → Read more…