NuGet Packaging
Package manager tool with the ability to produce and consume
packages, makes a clutter free references when installing/uninstalling
packages.
Upon installing a package will automatically add references added
in packages and update appropriate configuration files.
Pre-requisites
Available packaging options
1.
Command line
2. Package Explorer [GUI]
2. Package Explorer [GUI]
Packaging using command line
- Launch command prompt [run as administrator]
- Get in to NuGet executable path
- Pick the assembly you want to create package(for e.g. DocumentFormat.OpenXml.dll)
- Get in to NuGet installation folder and create “lib” folder
- Place the assembly to be packaged in lib folder
- Run the command in command prompt
- Creates a new spec file in the NuGet installation folder
- Open the spec file in notepad, and Update as per spec file mentioned below with appropriate details. Note: Do not copy content from the below mentioned spec file
- Run command in command prompt with appropriate version details of the assembly
- Package file will be created
Packaging using package explorer
- Launch NuGet Package Explorer and create new package
- Enter appropriate details in meta data and click tick mark in top left corner of the view
- Add lib folder to the package contents
- Right mouse click on lib folder and add .NET folder [this may change based on your usage]
- Right click on the .NET created on step above and add existing assembly file
- Save the package
- Verify the package in local folder
Consuming packages in projects using visual studio extension
- Launch Visual studio and select package manager console
- Click on Settings options located beside Package source list and add the location for local packages
- Package repositories from web locations can also be referred and added in package sources.
- Open project file to add references using NuGet Package
- Right mouse click on project file and select Manage NuGet Packages
- Select Local NuGet Packages Added in settings of package source in prior steps, you will be able to see packages dropped in the local folder
- Click Install
- Verify references in project references, assembly added in package will automatically added as reference to the project.
No comments:
Post a Comment