如何在构建事件中检索主要/次要/构建/修订版号

时间:2011-02-28 08:37:23

标签: visual-studio msbuild csproj post-build-event post-build

Hy那里!

我正在使用这段代码,在post-build-event上复制一些文件:

<PropertyGroup>
    <DemoPath1>..\demoPath1</DemoPath1>
</PropertyGroup>
<Target Name="AfterBuild">
    <Exec Command="robocopy $(ProjectDir)$(DemoPath1) $(ProjectDir)demoPath2/$(Revision) * /XD .svn _svn /XF *.cs /S" IgnoreExitCode="true" />
</Target>

正如你所看到的,我想使用$(Revision) - 显然,这不会起作用......

有人可以帮帮我吗?

@mods:我不知道要使用哪个标签......一方面它是msbuild,另一方面是视觉工作室......?随时编辑!

2 个答案:

答案 0 :(得分:2)

最简单的方法是:

<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
  <Output TaskParameter="Assemblies" ItemName="AssemblyVersion" />
</GetAssemblyIdentity>

我用这种方式:

<Exec Command="robocopy $(ProjectDir)$(SomeProperty) $(ProjectDir)somePath/%(AssemblyVersion.Version) * /S" IgnoreExitCode="true" />

答案 1 :(得分:0)

您遗漏了您想从中获取版本号的问题。无论如何,您需要做的就是自己填充$(Revision)属性。提供更多细节,我可以帮助你。