如何自动增加包版本号? [英] How do I auto increment the package version number?
问题描述
我意识到可以通过更改自动增加程序集的构建/修订号
I realize that the build/revision number of the assembly can be auto incremented by changing
[assembly: AssemblyVersion("1.0.0.0")]
到
[assembly: AssemblyVersion("1.0.*")]
在 AssemblyInfo.cs 文件中.
in the AssemblyInfo.cs file.
但是我如何自动增加 Package.appxmanifest 中定义的版本号?即,可通过以下方式访问的版本号:
But how do I auto-increment the version number defined in Package.appxmanifest? That is, the version number accessible through:
Windows.ApplicationModel.Package.Current.Id.Version
我使用的是 Visual Studio 2013.
I'm using Visual Studio 2013.
推荐答案
三行解决方案,按日期进行版本控制
我遇到了这个问题,直到我经过大量研究后才弄清楚如何在 .csproj
文件中仅用三行代码实现自动版本控制.这是:
Three line solution, versioning by date
I ran into that issue until I figured out after a lot of research how to achieve automatic versioning in just three line in the .csproj
file. Here it is:
<Target Name="NugetPackAutoVersioning" AfterTargets="Build">
<Exec Command="dotnet pack -p:PackageVersion=$([System.DateTime]::Now.ToString("yyyy.MM.dd.HHmmss")) --no-build --configuration $(Configuration) --output "$(SolutionDir)nuget"" />
</Target>
这将在nuget"中输出一个名为 {ProjectName}.{Year}.{Month}.{Day}.{Hour}{Minute}{Second}
的 NuGet 包.项目根目录下的文件夹,保证以后构建的包被版本化为后验.
This will output a NuGet package named like {ProjectName}.{Year}.{Month}.{Day}.{Hour}{Minute}{Second}
in a "nuget" folder at the project root, guaranteeing that packages built later are versioned as posteriors.
这篇关于如何自动增加包版本号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!