Get Started with Nexus and NuGet

Author, Damir Arh

Author, Damir Arh

The best way for getting to know Sonatype Nexus is to install its open source edition locally and give it a test run. Although you will want to have it running on a dedicated server in the end, your workstation should be good enough for initial testing. Don’t worry, you can disable it when you’re not testing it and it’s easy enough to do a clean uninstall, once you don’t need it any more. The instructions on how to do it are at the end of this article.

Basic Setup

Since Nexus comes bundled with Jetty application server, only one prerequisite remains: you need to have Java installed. A word of caution, though. On 64-bit Windows you’ll need the 64-bit version of Java. Since most browsers are still 32-bit, default Java installer for Windows installs the 32-bit runtime even on 64-bit Windows. To install the 64-bit version, you’ll need to download and install it manually. Both versions can coexist on the machine, so you can keep the 32-bit version alongside it for the browser.

Nexus OSS can be downloaded as a zip archive which you only need to unpack into a folder on your disk. The official instructions discourage you from putting it into Program Files folder; you’re best off just creating a Nexus folder in the root of your disk and putting it there. You’ll find 2 folders inside the archive: nexus-x.y.z-## containing the Nexus application itself (where the x.y.z-## part depends on the version) and sonatype-work being its default working folder. Make sure you put both in your destination folder.

You will need to install a Windows service from within the nexus-x.y.z-## folder. To avoid reinstalling the service with each new version, you don’t want the folder name changing. To achieve that either create a symbolic link (by calling mklink /d nexus nexus-2.9.1-02 in your destination folderwith administrative privileges) or rename the folder to nexus and upgrade the files in-place, if you’re not comfortable with that.

Install and Start Windows Service

Now you’re ready to install and start the Nexus Windows service. Navigate to nexus\bin subfolder and execute the following two commands with administrative privileges:

.\nexus.bat install
.\nexus.bat start

If there are any errors, you can find the log in nexus\logs\wrapper.log. I found the errors quite descriptive, so it shouldn’t be too hard to figure out, what’s wrong. By default the service is configured to automatically start on reboot. If you don’t want to have it running all the time while you’re just testing it, you will need to stop it after each reboot or change its configuration from the Services MMC snap-in (it is named nexus).

Once the service starts, you can access Nexus at the following URL: http://localhost:8081/nexus. By default there are only Maven (Java package manager) repositories registered; you’ll have to add the NuGet repositories yourself. We’ll delve into different types of repositories in the following articles; for now we’ll just create a simple proxy repository for NuGet Gallery, which will act as an intermediary between it and the client, locally caching the package catalog and packages.

Create a New Repository

To create a new repository, you’ll need to login into Nexus. You can find the default login credentials in the list of recommended post installation configuration steps. Once you’re logged in, open the list of repositories from the menu on the left and click on Add… > Proxy Repository in the toolbar above the repositories.

Get Started with Nexus and NuGet

You need to fill in the following data and save the changes:

To try it out, we’ll add this proxy repository as a new package repository to NuGet Package Manager extension for Visual Studio 2010, 2012 or 2013. Be careful when looking for its URL: it’s not the one listed in repository path column of repositories list; you need to select your repository in the list and click on the NuGet tab, to find it:

Get Started with Nexus and NuGet

In Visual Studio open the Manage NuGet Packages window and click on the settings button in its bottom left corner. This will open the options dialog where you can add a new package source. You can name it as you see fit, just make sure to put in the correct URL.

Get Started with Nexus and NuGet

After adding the new package source, you will be able to select it on the left side of Manage NuGet Packages window to use it instead of the default nuget.org package source. Try running a couple of searches against it to gain some confidence. In a large organization this should already give you some performance gains, since each user won’t individually hit nuget.org site anymore; and in the unlikely case of nuget.org not working, you will at least be able to work with packages that have already been cached by Nexus.

Get Started with Nexus and NuGet

 

Uninstall Nexus

As promised at the beginning of the article, I’ll conclude with instructions for uninstalling Nexus from your computer. Navigate first to nexus\bin folder and execute the following two commands:

.\nexus.bat stop
.\nexus.bat uninstall

You can now get rid of all its files by deleting the root Nexus folder, which you created. I hope, you’ll leave it there until the next article, though.

About the Author

Damir Arh has been involved with Microsoft technologies, since he has been a student. He has many years of experience with development and maintenance of complex enterprise software in the field of document management, insurance, and process management. Recently he has shown increased interest in the heterogeneous ecosystem of mobile devices and cross-platform development.

Damir is always looking for tools and processes to make development easier and more manageable, making him a big proponent of test driven development, continuous integration and continuous deployment. He coauthored a book on NuGet – the package manager for .NET framework.

He likes to share his knowledge with others by answering questions on Stack Overflow, blogging and regularly speaking at local user groups and conferences. For his contributions to the community he is an awarded Microsoft MVP since 2012.

Blog: http://www.damirscorner.com
Twitter: http://twitter.com/DamirArh

The following two tabs change content below.

Damir Arh

Damir Arh has been involved with Microsoft technologies, since he has been a student. He has many years of experience with development and maintenance of complex enterprise software in the field of document management, insurance, and process management. Recently he has shown increased interest in the heterogeneous ecosystem of mobile devices and cross-platform development. Damir is always looking for tools and processes to make development easier and more manageable, making him a big proponent of test driven development, continuous integration and continuous deployment. He coauthored a book on NuGet – the package manager for .NET framework. He likes to share his knowledge with others by answering questions on Stack Overflow, blogging and regularly speaking at local user groups and conferences. For his contributions to the community he is an awarded Microsoft MVP since 2012.
Authors

Related posts

*

Top