简体   繁体   English

从项目信息设置Nuget软件包版本

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

相关问题 从打包的程序集版本中拾取NuGet程序包版本 - Pickup NuGet package version from the packed assembly version 当操作来自 NuGet package 时,如何在多目标项目上操作 Packageversion - How can I manipulate the Packageversion on a multi target project when manipulation comes from a NuGet package 在 dockerfile 中构建项目时,“无法找到后备包文件夹”nuget 错误来自哪里? - where does the "Unable to find fallback package folder" nuget error come from, when building project in a dockerfile? 无法将nuget软件包设置为@Prerelease VSTS - Unable to set nuget package as @Prerelease VSTS 在构建期间无法自动将NuGet包更新到最新版本 - Cannot automatically update a NuGet package to the latest version during build 使用内部版本号作为nuget-package-version - Use build-number as nuget-package-version 在Visual Studio中构建项目时如何安装Nuget包 - How install Nuget package when building project in Visual Studio 如何使用修改后的 chromedriver 从 Nuget package 提供 Selenium? - How to provide Selenium from Nuget package with modified chromedriver? 在构建时设置.net核心库程序集/文件/ nuget包版本 - Setting .net core library assembly/file/nuget package version at build time 如何自动检查本地nuget服务器上具有相同版本的软件包是否有更新 - How check automatically if there is an update on a package in my local nuget server with the same version
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM