在VS2017中,在构建后事件中,我包含一个Powershell脚本:
powershell "start-process powershell.exe -ArgumentList '$(ProjectDir)Resources\PostBuild.ps1',
'$(ProjectDir)', '$(TargetDir)', '$(ConfigurationName)', '$(SolutionName)'"
在那个PS脚本中,我阅读了生成的程序集以获取发布版本:
$ass = [System.Reflection.Assembly]::LoadFile($file)
# This gets the AssemblyVersion:
$v = $ass.GetName().Version
$version = [string]::Format("{0}.{1:00}.{2:00}.{3}",$v.Major, $v.Minor, $v.Build, $v.Revision)
Write-Host $version
# This gets the ProductVersion and the FileVersion:
$FVI = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($file)
Write-Host $FVI
但是,上面的示例PS代码为我提供了程序集版本,产品版本和文件版本,但我找不到获取 发布版本 的方法。谁能告诉我怎么做?
我找到了很多关于汇编版本的示例,但没有找到发布版本的示例。
谢谢。
Powershell的答案(而不是比起C#赞赏。