在构建时生成NuGet包 [英] Generate NuGet package on build

查看:352
本文介绍了在构建时生成NuGet包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用"在构建时生成NuGet包"时Visual Studio 2017中的选项,如何正确包含本机运行时库。在过去,nuspec文件将引用本机DLL,并且您将包含.targets文件,但它不是
清除如何从项目设置中的Package选项卡复制.targets文件的功能。在任何地方都有这样的例子吗?

When using the "Generate NuGet package on build" option in Visual Studio 2017, how do you properly include native runtime libraries. In the past, the nuspec file would reference the native DLLs, and you would include a .targets file, but it isn't clear how to replicate the functionality of the .targets file from the Package tab in the project settings. Are there any examples of this anywhere?

推荐答案

嗨  jackhanbond,

Hi jackhanbond,

>>>  ; 如何从项目设置中的"包"选项卡复制.targets文件的功能。在任何地方都有这样的例子吗?

>>> how to replicate the functionality of the .targets file from the Package tab in the project settings. Are there any examples of this anywhere?

答案是肯定的,但是我们无法直接在项目设置的"包"选项卡中包含&.bspgets文件。正如您在"包"选项卡中所看到的,"包"选项卡仅包含一些基本的nuget包信息设置。如果要包含
本机运行时库,可以在项目文件.csproj文件中添加以下代码:

The answer is yes, but we could not including the .targets file directly from Package tab in the project settings. As you can see in the Package tab, the package tab only contains some basic nuget package information settings. If you want to include native runtime libraries, you can add following code in your project file .csproj file:

  <ItemGroup>
    <None Include="ClassLibrary1.targets">
      <Pack>true</Pack>
      <PackagePath>build</PackagePath>
    </None>
  </ItemGroup>

然后打包你的项目,MSBuild会将.targets文件包含到build文件夹中:

Then you pack your project, MSBuild will include the .targets file into the build folder:

请参阅  ; NuGet打包并恢复为MSBuild目标以获取更多详细信息。

See NuGet pack and restore as MSBuild targets for more details.


这篇关于在构建时生成NuGet包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆