NuGet
Last updated
Was this helpful?
Last updated
Was this helpful?
NuGet is the package manager for .NET
→ ,
An essential tool for any modern development platform is a mechanism through which developers can create, share, and consume useful code. Often such code is bundled into "packages" that contain compiled code (as DLLs) along with other content needed in the projects that consume these packages.
For .NET, the Microsoft-supported mechanism for sharing code is NuGet, which defines how packages for .NET are created, hosted, and consumed, and provides the tools for each of those roles.
→
AutoMapper
Dapper
FluentAssertions
FluentValidation
ImageSharp
MediatR
Moq
Selenium WebDriver
xUnit
Self-update: nuget update -self
Create spec file: nuget spec
Create packages: nuget pack
Azure Packages
Provided by Azure DevOps
MyGet
ProGet
NuGet Server
NuGet Gallery
Solutions available (list not exhaustive!):
Pros: very easy to setup (less than 5 minutes), secure, free account (limited but more than enough for personal projects and evaluate), available on internet, works well with VSTS, no maintenance of infra cost
Pros: natively integrated with VSTS Build, no maintenance of infra cost
Cons: seems like the only free solution BUT time needed to setup (creation of the solution, build & deploy) and maintain the server hosting the solution (+ infra cost), by default no backup or feed on internet
4/ Sonatype Nexus
Cons: community version do not manage NuGet feeds AND infra/maintenance cost plus feeds not on internet by default
Tips:
Prerequisites:
NuGet server (needs to be defined):
In your VSTS project Settings section (wheel icon) go in "Services" page
In "Endpoints" click on "New Service Endpoint" and select "NuGet"
Fill the different elements (this is very easy if you are using MyGet, the feed URL and ApiKey have been displayed when you configured your feed)
Steps:
.NET Core > Restore: nothing particular here (don't forget the NuGet.config file if you are using other feeds than nuget.org)
.NET Core > Build: nothing particular here
.NET Core > Test: nothing particular here
NuGet > NuGet push:
Target feed location = External NuGet server (including other accounts/collections)
Nuget Server = the name of the server you defined earlier
Tips:
1/ Update your build definition in VSTS
2/ Update your project file and add VersionPrefix
and VersionSuffix
3/ Use MSBuild to control how you build your NuGet packages
,
→
1/
2/ with
3/ Host & deploy a web application referencing
Do not forget to add a NuGet.config
file at the root of the solutions that will use the library (see and ). Otherwise you won't be able to do on build systems such as VSTS. Example:
→
.NET Core > dotnet pack: as of today (Feb 2018), you cannot use "NuGet pack in VSTS" but you can do a "dotnet pack" instead (ref discussion on ).
By default, the NuGet package will always have the version 1.0.0 (). There are 3 solutions: