Search code examples
visual-studiomsbuildcsprojpost-build-eventpost-build

How can I retrieve major/minor/build/revision number on build events


Hy there!

I'm using this piece of code, to copy some files on 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>

As you can see, I would like to use $(Revision) - obviously, this is not going to work ...

Can anybody help me out?

@mods: I dunno exactly which tag to use ... on the one hand it's msbuild, on the other one visual studio ...? feel free to edit!


Solution

  • The easiest way is:

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

    and I've used it this way:

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