【问题标题】:Is it possible to get Product Version in post build event?是否可以在构建后事件中获取产品版本?
【发布时间】:2014-01-31 12:38:41
【问题描述】:

我希望在构建完成后将 MyDir(在我的 $ProjectDir 中)复制到 $OutDir{ProductVersion}。

在 csproj 文件中使用以下配置,我可以获得文件版本。

<Target Name="AfterBuild">
    <GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
      <Output TaskParameter="Assemblies" ItemName="AssemblyVersion" />
    </GetAssemblyIdentity>
    <Exec Command="robocopy $(ProjectDir)MyDir $(OutDir)/%(AssemblyVersion.Version) /E" IgnoreExitCode="true" />
</Target>

但是,这会检索 FileVersion 而不是 ProductVersion。有什么方法可以在构建后事件中获取 ProductVersion 吗?

【问题讨论】:

    标签: visual-studio-2010 version post-build-event


    【解决方案1】:

    您正在寻找Read AssemblyFileVersion from AssemblyInfo post-compile。为此,您将需要一个自定义任务,因为 GetAssemblyIdentity 不返回产品版本。

    链接的问题有 AssemblyFileVersion 的答案,调整它以使其返回 ProductVersion 应该不难。

    【讨论】:

      猜你喜欢
      • 2011-11-26
      • 2021-02-06
      • 2011-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-30
      • 1970-01-01
      相关资源
      最近更新 更多