With Powershell 5 comes Package Management which has the potential for becoming the number one tool used when it comes to application deployment. Rather than relying on community written packages from say, Chocolatey, I want to be able to set up my own internal repo to have full control over packages and how they work.
Setting up the NuGet Server
Firstly get a up to date instance of 2012 R2 running and install IIS and ASP .NET 4.5
Install-WindowsFeature -Name Web-Server,Web-Asp-Net45 -Verbose
Next get Visual Studio installed and up to date and create a new empty ASP.NET Web Application. For this I will be using Visual Studio 2015 Community Edition which can be downloaded here
- Start > New Project > ASP.NET Web Application Empty
Now we need to install Nuget.Server via NugetPackage Manager.
- Right Click References > Manage NuGet Packages > Search for Nuget.Server > Install
If you have trouble finding the package you might want to check your settings. In Options under NuGet Package Manager under Package Sources you should have the link https://api.nuget.org/v3/index.json. (This may vary on between Visual Studio versions)
Once installed you can edit Web.Config to point to a specific directory for Package
<add key="packagePath" value="" />
Building the Solution
Now we Need to configure Visual Studio to use IIS instead of its internal IIS Express. To do this:
- Right Click Project Name > Properties
- Click Web > Under Servers Select “Local IIS” > Click Create Virtual Directory
Finally the Solution is ready to Build:
- Right Click Project Name > Build
You should now see your application in IIS and be able to browse to the website.
Your Nuget Server is now setup and running. To Test you can drop some previously downloaded .nupkg files into your package path defined in Web.Config. You should be able to browse these at http://localhost/<ProjectName>/nuget.