Creating and Publishing a Package
- Download NuGet.exe
- Make sure NuGet.exe is in your path
For simple packages, creating a package from a csproj file is a convenient way to create packages.
nuget pack qqqq.csproj
nuget pack qqqq.csproj -IncludeReferencedProjects
nuget pack MyProject.csproj -Prop Configuration=Release
nuget pack -sym qqqq.csproj
To create a package in this way, you can layout a directory structure that follows the NuGet conventions.
- tools – The tools folder of a package is for powershell scripts and programs accessible from the Package Manager Console. After the folder is copied to the target project, it is added to the `$env:Path (PATH) environment variable.
- lib – Assemblies (.dll files) in the lib folder are added as assembly references when the package is installed.
- content – Files in the content folder are copied to the root of your application when the package is installed.
- build – The build folder of a package is for MSBuild targets files that are automatically inserted into the .csproj file of the application.
create the folders needed by your package and copy the correct content in each folder.
A package is considered a solution-level package if it does not contain any files in its lib, content, or build directories. If the package has dependencies, they also must not have files in their lib, content, or build directories.
When a solution-level package is installed, it is tracked in a packages.config file in the .nuget directory, rather than in a packages.config file in a specific project.
Solution level packages are not supported in NuGet 3.0.0-3.2.0, and you will need to install such packages into a common project.
At the top of your file, add this line:
param($installPath, $toolsPath, $package, $project)
$installPathis the path to the folder where the package is installed
$toolsPathis the path to the tools directory in the folder where the package is installed
$packageis a reference to the package object.
$projectis a reference to the EnvDTE project object and represents the project the package is installed into.
When NuGet installs a package with \build files, it will add an MSBuild element in the project file pointing to the .targets and .props files. The .props file is added at the top, whereas the .targets file is added to the bottom.
A package can include a readme.txt file in the root of the package. This file will be displayed in Visual Studio immediately after the package is installed.
When NuGet installs an assembly from a package, it checks the target .NET Framework version of the project you are adding the package to.
The following example shows a .nuspec file that specifies files
The following example shows a .nuspec file that specifies framework assemblies.
nuget package explorer (GUI tool)