简体   繁体   English

NuGet Pack-针对nuspec或csproj打包的不同问题

[英]NuGet Pack - Different Problems Packing Against nuspec or csproj

I've run into a bit of a catch-22 here. 我在这里碰到了22。 I'm using NuGet and TeamCity. 我正在使用NuGet和TeamCity。 I've tried doing NuGet pack with the nuspec file, and I've also tried with the csproj file. 我尝试使用nuspec文件进行NuGet pack ,也尝试使用csproj文件。 Each has its own issue: 每个都有自己的问题:

In TeamCity, if I use the nuspec file with NuGet pack , the $version$ token, in the nuspec file, doesn't get updated. 在TeamCity中,如果我将nuspec文件与NuGet pack一起使用,则nuspec文件中的$version$令牌不会更新。

If I change TeamCity to NuGet pack using the csproj file, the $version$ token gets updated, however the resulting package only has the EXE in it, and all of the dependent assemblies are missing. 如果我使用csproj文件将TeamCity更改为NuGet pack则会更新$version$令牌,但是生成的包中仅包含EXE,并且所有相关程序集都丢失了。 This problem doesn't happen when using the nuspec file. 使用nuspec文件时不会发生此问题。

Is there a way to get the best of both worlds? 有没有办法做到两全其美? I'd like the $version$ token to be updated (which works when using csproj), and I'd like the dependent assemblies to be included in the package (which works when using nuspec). 我希望更新$version$令牌(在使用csproj时有效), 并且我希望依赖程序集包含在包中(在使用nuspec时有效)。

Note: I'm hoping there is a solution that doesn't involve creating PowerShell scripts, or something that couples the code/project to the build technology (TeamCity). 注意:我希望有一种解决方案不涉及创建PowerShell脚本,或将代码/项目与构建技术(TeamCity)耦合的解决方案。

I was able to achieve using the $version$ variable and having the dependent assemblies included in the package. 我能够使用$ version $变量并在包中包含相关程序集来实现。 What did it was including this in the nuspec file: 在nuspec文件中包括了什么:

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

So basically everything in bin\\release ends up in the content folder in the package. 因此,基本上bin \\ release中的所有内容最终都位于软件包的content文件夹中。 I'm not sure if the content folder is the right spot, but at least it's there. 我不确定内容文件夹是否正确,但至少它在那里。 I can change the target later, if needed. 如果需要,我可以稍后更改目标。

Summary: 摘要:
- TeamCity builds against the csproj file -TeamCity根据csproj文件构建
- The nuspec file has $version$, and it gets updated -nuspec文件具有$ version $,并且已更新
- The nuspec file specifies the files to include (see above) -nuspec文件指定要包含的文件(请参见上文)

The right way to go here would be to pack against a csproj but have a corresponding nuspec file present with $version$ token for the Version nuspec metadata. 正确的选择是打包一个csproj,但要有一个对应的nuspec文件,该文件带有用于版本nuspec元数据的$ version $令牌。 NuGet would prefer metadata values from nuspec , and if they are tokens which are not passed through , it will look at assembly metadata to substitute it appropriately. NuGet会首选nuspec中的元数据值,如果它们是未传递的令牌,它将查看程序集元数据以适当地替换它。

That said, if you find this is not the expected behavior, please file an issue at https://github.com/nuget/home/issues and the NuGet team will be happy to help you solve your issue. 就是说,如果您发现这不是预期的行为,请在https://github.com/nuget/home/issues提交问题,NuGet团队将很乐意为您解决问题。

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

相关问题 带有自定义 .nuspec 元数据的 nuget 包 .csproj - nuget pack .csproj with custom .nuspec metadata nuget-packing csproj与nuspec之间的差异 - Differences between nuget-packing a csproj vs. nuspec 从nuspec文件的不同文件夹中包含的多个csproj创建多目标nuget包 - Create multi-target nuget package from several csproj contained in different folders from nuspec file 无法使用 dotnet CLI 和 nuspec 文件打包 NuGet 包 - Unable to pack a NuGet package using dotnet CLI and nuspec file 如何在生成的 .nuspec 的 MSBuild NuGet 包中注入自定义依赖项 - How to inject a custom dependency in an MSBuild NuGet pack generated .nuspec 使用 Nuget 包创建 Nuget Package 说要将 net6.0 的依赖组添加到 nuspec 和需要的点? - Creating a Nuget Package with Nuget Pack Says to Add a dependency group for net6.0 to the nuspec and Dots Required? Nuget pack 3.4.3 csproj + project.json包含依赖项 - Nuget pack 3.4.3 csproj + project.json include dependencies Azure DevOps NuGet Pack 忽略 csproj 包详细信息 - Azure DevOps NuGet Pack is ignoring csproj package details 使用NuGet Pack时,是否可以指定没有nuspec文件的软件包名称? - When using NuGet Pack is it possible to specify the package name without a nuspec file? 如何在没有任何nuspec文件的情况下将多个项目中的产品打包到一个nuget中? - How to pack the products from multiple projects into one nuget without any nuspec file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM