如何自动增加包版本号? [英] How do I auto increment the package version number?

查看:43
本文介绍了如何自动增加包版本号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意识到可以通过更改自动增加程序集的构建/修订号

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.

但是我如何自动增加 P​​ackage.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(&quot;yyyy.MM.dd.HHmmss&quot;)) --no-build --configuration $(Configuration) --output &quot;$(SolutionDir)nuget&quot;" />
</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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆