0

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!

  • @Cody Gray: thanks for tagging! –  Feb 28 '11 at 08:41
  • possible duplicate of [Determine Assembly Version during a Post Build Event?](http://stackoverflow.com/questions/2243593/determine-assembly-version-during-a-post-build-event) –  Feb 28 '11 at 12:14

2 Answers2

2

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" />
  • Are you sure that AssemblyVersion.Version is correct? It doesn't get me anything, at least AssemblyInfo.Version returns 0.0.0.0 - although thats wrong too, as it does not match my settings in the AssemblyInfo.cs – AgentKnopf May 30 '13 at 12:45
  • are you referencing the correct assembly in the `GetAssemblyIdentity`-task? –  May 31 '13 at 06:14
  • I am referencing the executable generated by my project by using AssemblyFiles="$(TargetDir)\$(TargetName).exe. The $(TargetDir)\$(TargetName).exe is also used in the following copy task and the correct .exe file is copied, so I assume the way I reference it is correct. But could it be an issue, that it's an executable, rather than a DLL file? – AgentKnopf May 31 '13 at 06:51
0

You left out of your question where you want to get the version number from. However you get it, all you need to do is populate the $(Revision) property yourself. Give a little more detail and I can probably help you out.

Brian Kretzler
  • 9,748
  • 1
  • 31
  • 28