[英]Is there an easy way to automatically create a NuGet package from a Visual Studio 2015 project?
Before Visual Studio 2015, it was trivial to setup your project to automatically generate NuGet packages. 在Visual Studio 2015之前,将项目设置为自动生成NuGet包非常简单。 Specifically, you did: 具体来说,你做了:
<BuildPackage>
to true 编辑项目.csproj文件并将构建属性<BuildPackage>
为true And that was it! 就是这样!
However, starting from VS 2015, MSBuild-integrated package restore has been removed and replaced by the new Automatic Package Restore. 但是,从VS 2015开始, 已删除MSBuild集成的程序包还原,并替换为新的自动程序包还原。 While these are all good news, it seems that setting the build property <BuildPackage>
to true no longer triggers an automatic package build. 虽然这些都是好消息,但似乎将构建属性<BuildPackage>
为true不再触发自动包构建。
This is a major break of functionality! 这是功能的重大突破! Is there a way to setup automatic builds of NuGet without using post-build events? 有没有办法在不使用后期构建事件的情况下设置NuGet的自动构建? Specifically, I'm looking for an MSBuild solution, as it forms the backbone of my build workflow. 具体来说,我正在寻找一个MSBuild解决方案,因为它构成了我的构建工作流程的支柱。
Try OctoPack: https://www.nuget.org/packages/OctoPack/ 试试OctoPack: https ://www.nuget.org/packages/OctoPack/
Just add nuget package to your project. 只需将nuget包添加到您的项目中即可。
If you want to build it every time you build release, add to section <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Whatever' ">
next line: 如果您想在每次构建版本时构建它,请添加到<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Whatever' ">
下一行:
<RunOctoPack>true</RunOctoPack>
More information about finetuning can be found here: https://github.com/OctopusDeploy/OctoPack 有关微调的更多信息,请访问: https : //github.com/OctopusDeploy/OctoPack
There is a move to Class Library Packages in VS2015 which makes it incredibly easy to create NuGet packages. VS2015中有一个类库包的转移,这使得创建NuGet包非常容易。 I've blogged about this before, but essentially it's just a few steps. 我之前曾在博客上发表过这篇文章,但基本上只是几个步骤。 Note that this is just a RC1 at the moment and not a stable release yet. 请注意,目前这只是一个RC1,而不是一个稳定的版本。
Install the ASP.NET and Web Tools 2015 (RC1 Update 1) update to VS2015. 将ASP.NET和Web Tools 2015(RC1 Update 1)更新安装到VS2015。
Open VS2015 and create a new Class Library Package project. 打开VS2015并创建一个新的类库包项目。
Add your code to the library and configure the project.json file with any changes you may need. 将代码添加到库中,并使用您可能需要的任何更改配置project.json文件。 A default project.json file is used as an example. 以默认的 project.json文件为例。
Right-click on the project and select the Properties menu item. 右键单击项目,然后选择“属性”菜单项。 In the Build tab select “Produce outputs on build”. 在“构建”选项卡中,选择“在构建时生成输出”。 Build the project. 建立项目。
You're done. 你完成了。 Go to the artifacts folder in your project, in my case “artifacts\\bin\\AwesomeSoft.TextConverter\\Debug”. 转到项目中的artifacts文件夹,在我的例子中是“artifacts \\ bin \\ AwesomeSoft.TextConverter \\ Debug”。
You should see the NuGet package already created, and the folders targeting each framework specified earlier. 您应该看到已经创建的NuGet包,以及针对之前指定的每个框架的文件夹。
There is another alternative called NuPack : 还有另一个名为NuPack的替代方案:
How-to-create-a-nuget-package-on-each-Visual-Studio-with-NuPack 如何对创建-A-的NuGet-封装上的每个视听工作室与- NuPack
It is a nuget package that automatically generate nuget package on build time. 它是一个nuget包,可以在构建时自动生成nuget包。
VS4MAc already supports this and you can get it as a extension for VS on Windows VS4MAc已经支持此功能,您可以将其作为Windows上VS的扩展
https://github.com/NuGet/NuGet.Build.Packaging https://github.com/NuGet/NuGet.Build.Packaging
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.