如何创建和使用ASP.NET vNext类库NuGet包? [英] How to create and use ASP.NET vNext class library NuGet package?
问题描述
我想创建我的ASP.NET vNext类库的NuGet包.我该怎么做,一步一步来?我知道这里有kpm build
,但是找不到有关在哪里下载kpm等的指南.
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.
此外,在获得NuGet程序包(或DLL)之后,如何将其从本地计算机添加到我的vNext项目中?
Also, after getting a NuGet package (or DLL) of it, how can I add it from local machine to my vNext project?
推荐答案
从类库创建NuGet包
如果您使用 Visual Studio 2015 RC 及更高版本:转到类库项目属性,打开Build
选项卡并选中Produce outputs on build
选项:
Creating NuGet package from class library
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软件包将在每个项目版本的{SolutionDir}\artifacts\bin\{ProjectName}\{Configuration}
目录中创建.
NuGet package will be created in {SolutionDir}\artifacts\bin\{ProjectName}\{Configuration}
directory on each project build.
如果使用命令行:
- 确保已安装
DNVM
和DNX
(有关说明,请参见 ASP.NET Home存储库) ). - 在项目目录中运行
dnu pack
.默认情况下,将在{ProjectDir}\bin\{Configuration}
目录中创建NuGet软件包.
- Make sure you installed
DNVM
andDNX
(see ASP.NET Home repo for instructions). - Run
dnu pack
in the project directory. NuGet package will be created in{ProjectDir}\bin\{Configuration}
directory by default.
使用打包的类库
要在同一解决方案的另一个项目中使用类库,请将其添加为Visual Studio中的常规项目引用,或添加至project.json
中的dependencies
属性:
"dependencies": {
"ClassLibrary1": ""
}
要在其他解决方案中使用该库,请将NuGet程序包发布到 nuget.org 或任何其他NuGet提要和使用Visual Studio(References
〜> Manage NuGet Packages...
)将其添加到您的项目中,或将其添加到project.json
中的dependencies
属性中.
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
.
这篇关于如何创建和使用ASP.NET vNext类库NuGet包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!