【发布时间】:2020-01-09 03:21:29
【问题描述】:
对于我在 csproj 中的版本标签,我有以下内容:
<PropertyGroup>
<Version>
$([System.DateTime]::UtcNow.Year).$([System.DateTime]::UtcNow.ToString("MM")).$([System.DateTime]::UtcNow.ToString("dd")).$([System.DateTime]::UtcNow.ToString("HHmm"))
</Version>
</PropertyGroup>
但它的输出如下:Vysn.Voice.2020.1.9.309.nupkg 用于 nuget 包,当我从程序集中获取版本信息时:Assembly.GetExecutingAssembly().GetName().Version。
但是当我这样做时
var assembly = Assembly.GetExecutingAssembly();
var informationalVersionAttribute = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
Console.WriteLine(informationalVersionAttribute.InformationalVersion);
它输出正确的 DateTime 字符串:2020.01.08.1018。我不确定我在指定版本时是否做错了,但我希望它正确输出版本:2020.MM.dd.HHmm。
【问题讨论】:
标签: asp.net-core .net-core msbuild csproj