[英]Set Nuget Package Version from Project Info
My setup is rather simple: MyGet pulls my repo from GitHub on commit and builds. 我的设置非常简单:MyGet在提交和构建时从GitHub中提取我的仓库。 I then manually push the successfully built project to NuGet. 然后,我手动将成功构建的项目推送到NuGet。
The version is manually set except for the build counter. 该版本是手动设置的,除了生成计数器。 Is there a way to pull the version from the AssemblyInfo, .csproj file or somewhere else? 有没有办法从AssemblyInfo,.csproj文件或其他地方提取版本?
I've read the docs and the only thing I can find is using GitVersion and a build file. 我已经阅读了文档,唯一能找到的就是使用GitVersion和构建文件。 I'm hoping there's a cleaner/simpler way, eg %project_version% :) 我希望有一种更简洁的方法,例如%project_version%:)
By definition, a build counter is managed by the build system and can only be reset at best. 根据定义,构建计数器由构建系统管理,并且最多只能重置。
To use the version from AssemblyInfo.cs
as the NuGet package version, you could create a .nuspec
manifest next to your .csproj
file (give it the same file name only differing by extension), and use the $version$
placeholder. 要将AssemblyInfo.cs
的版本用作NuGet软件包版本,可以在.csproj
文件旁边创建一个.nuspec
清单(给它相同的文件名,但扩展名不同),然后使用$version$
占位符。
I've got a blog post that explains this in further detail: https://www.xavierdecoster.com/post/2012/04/26/nuget-version-token-explained.html 我有一篇博客文章对此进行了更详细的解释: https : //www.xavierdecoster.com/post/2012/04/26/nuget-version-token-explained.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.