I would like to create a NuGet package of my ASP.NET vNext class library. How can I do it, step by step? I understand there is kpm build
, but I couldn't find a guide regarding where to download kpm, etc.
Also, after getting a NuGet package (or DLL) of it, how can I add it from local machine to my vNext project?
Open your Visual Studio application. On the Tools menu, select Options. Expand the NuGet Package Manager and select Package Sources. Click the Add button (green plus), and enter the 'Package Name' and 'Package Source URL' of the Syncfusion ASP.NET Web Forms NuGet packages.
Right-click on project menu and select Publish. Select the option to publish to a Folder.
Kpm is the package manager for the new KRuntime. Instructions on how to install the KRuntime command line utilities on your developer machine can be found on the aspnet Home repo. Once you have kvm and a version of the KRuntime set up you will have kpm available as well.
Now you can run kpm build
on your class libraries project location. Output should be something like this:
kpm build src\ClassLibrary1\
ClassLibrary1 -> C:\Users\username\Documents\Visual Studio 14\Projects\WebApplication1\src\ClassLibrary1\bin\Debug\ClassLibrary1.1.0.0.nupkg
ClassLibrary1 -> C:\Users\username\Documents\Visual Studio 14\Projects\WebApplication1\src\ClassLibrary1\bin\Debug\ClassLibrary1.1.0.0.symbols.nupkg
Build succeeded.
0 Warnings(s)
0 Error(s)
Time elapsed 00:00:01.7556414
The easiest way to add a reference to a class project is to do it in your project.json, assuming you have it in the same solution. Here is an example project.json from a web application, which references a class library called ClassLibrary1.
{
"webroot" : "wwwroot",
"exclude": "wwwroot/**/*.*",
"dependencies": {
"Microsoft.AspNet.Server.IIS": "1.0.0-alpha4",
"ClassLibrary1": ""
},
"frameworks" : {
"aspnet50" : { },
"aspnetcore50" : { }
}
}
If you want to set up a NuGet feed you can read the official NuGet documentation to see how that is done. Copy the outputs of kpm build
into your NuGet feed.
Note: VS14 CTP4 only works with alpha4 of the KRuntime. If you want to use VS14 for vNext without errors popping up you need to downgrade your KRuntime to version 1.0.0-alpha4.
If you use Visual Studio 2015 RC and later: go to your class library project properties, open Build
tab and check Produce outputs on build
option:
NuGet package will be created in {SolutionDir}\artifacts\bin\{ProjectName}\{Configuration}
directory on each project build.
If you use command line:
DNVM
and DNX
(see ASP.NET Home repo for instructions).dnu pack
in the project directory. NuGet package will be created in {ProjectDir}\bin\{Configuration}
directory by default.To use the class library in another project from the same solution, add it as a usual project reference in Visual Studio or to dependencies
property in project.json
:
"dependencies": {
"ClassLibrary1": ""
}
To use the library in other solutions, publish NuGet package to nuget.org or any other NuGet feed and add it to your project using Visual Studio (References
~> Manage NuGet Packages...
) or to dependencies
property in project.json
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With