Skip to content

Instantly share code, notes, and snippets.

@davamix
Last active August 20, 2016 19:30
Show Gist options
  • Save davamix/938d1b29d06b8b9c95d699e17c94d346 to your computer and use it in GitHub Desktop.
Save davamix/938d1b29d06b8b9c95d699e17c94d346 to your computer and use it in GitHub Desktop.
Create and configure a local NuGet server

Nuget Server

  • Create an ASP.NET web project with the Empty template
  • Install the Nuget.Server package
  • Publish the project to the IIS server

Publish options:

Connection

- Publish method: Web deploy
- Server: localhost (no port number)
- Site name: NugetServer (site name in IIS)
- Destination URL: http://localhost:8080 (site address)

Settings

- Configuration: Release
- Check “Exclude file from the App_Data folder”

Nuget Package

  • Create the .nuspec file for the project
nuget.exe spec

(run this command where the .csproj file is located)

  • Complete the data in the new file created

  • Build the project in Release mode and generate the nuget package with:

     nuget.exe pack Project.csproj -Prop Configuration=Release 
    
  • Copy the .nupkg file created into the Packages folder of the NugetServer

Visual Studio

  • Configure the Nuget repository in VS

  • Tools -> Nuget Package Manager -> Package Manager Settings -> Package Sources

  • Add a new one

Automatise the package creation

  • Create a folder Tools in your solution and copy the nuget.exe file into it
  • Create a Post-Build event in the project to create the nuget package automatically and move it to the Packages folder of the Nuget server
$(SolutionDir)/Tools/nuget.exe pack "$(ProjectPath)" -Prop Configuration=Release

if exist "$(TargetDir)*.nupkg" (
	move "$(TargetDir)*.nupkg" \\NuGetServer\Packages\
)

Be sure that the version of the library has been incremented after the build. I use Automatic Versions

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment