简体   繁体   English

将目标打包到nuget为客户

[英]Pack targets into nuget for clients

I'm creating nuget package that have some targets that should be installed for developers that use my package, ie in file my-targets.targets I have this lines: 我正在创建nuget包,其中包含一些应该为使用我的包的开发人员安装的目标,即在文件my-targets.targets我有这样的行:

  <Target Name="CleanGenerated" AfterTargets="Clean">
    ... do smthing ...
  </Target>
  <Target Name="Generate" BeforeTargets="Build">
    ... do smthing ...
  </Target>

How should I embeded this file with nuget so other developers would have those 2 build steps? 我应该如何使用nuget嵌入此文件,以便其他开发人员可以使用这两个构建步骤?

In the documentation , section "Including MSBuild props and targets in a package" you can read that you need to create a file with a ".targets" extension. 文档的 “在程序包中包含MSBuild道具和目标”部分中,您可以读到需要创建一个扩展名为“.targets”的文件。 Place that file in a "build" directory below the project root. 将该文件放在项目根目录下的“构建”目录中。 In the NuSpec file you need to add a reference to that section: 在NuSpec文件中,您需要添加对该部分的引用:

<metadata>
  ...
</metadata>
<files>
   <file src="build\**" target="build" />
</files>

Depending on your NuGet version the installation of the package will behave differently; 根据您的NuGet版本,程序包的安装行为会有所不同; see the documentation for more details. 有关详细信息,请参阅文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM