[英]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.