NuGet Pack - Different Problems Packing Against nuspec or csproj

三世轮回 提交于 2019-12-02 15:51:51

问题


I've run into a bit of a catch-22 here. I'm using NuGet and TeamCity. I've tried doing NuGet pack with the nuspec file, and I've also tried with the csproj file. 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.

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. This problem doesn't happen when using the nuspec file.

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).

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).


回答1:


I was able to achieve using the $version$ variable and having the dependent assemblies included in the package. What did it was including this in the nuspec file:

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

So basically everything in bin\release ends up in the content folder in the package. 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
- The nuspec file has $version$, and it gets updated
- The nuspec file specifies the files to include (see above)




回答2:


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. 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.

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://stackoverflow.com/questions/48360009/nuget-pack-different-problems-packing-against-nuspec-or-csproj

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!