0

I wanna use Version Number stated inside AssemblyInfo.cs as foldername in Post-Build Command Line.. How can I extract out the version number as a variable to set as the folder name? or is there any other alternative ways?

I tried using sed tools and filever but it doesn't seems to work as mention in this post Determine Assembly Version during a Post Build Event?

Community
  • 1
  • 1
I Yeu C
  • 636
  • 2
  • 7
  • 13
  • take a look at http://stackoverflow.com/questions/5139709/how-can-i-retrieve-major-minor-build-revision-number-on-build-events – Mike Miller Feb 27 '12 at 09:54
  • Sorry I'm new at this I don't really get what it mean. Can you briefly explain to me? – I Yeu C Feb 28 '12 at 01:33

1 Answers1

0

You need to add/edit the AfterBuild target in your build file, this build file might be the csproj/vbproj file for your project depending on what you are trying to achieve. If you add this

  <Target Name="AfterBuild">
    <GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
        <Output TaskParameter="Assemblies" ItemName="AssemblyVersion"/>
    </GetAssemblyIdentity>  
    <Copy SourceFiles="$(TargetPath)" DestinationFiles="C:\build\%(AssemblyVersion.Version)\$(TargetName).dll" />   
  </Target>

It will copy the Assembly build by the csproj file in this case to C:\build\version number\myassembly.dll.

Mike Miller
  • 16,195
  • 1
  • 20
  • 27
  • I have AssemblyVersion.Version and it returns 0.0.0.0 (does not match my version set in the Assembly.cs which is 1.0.0) but when I use your AssemblyVersion.Version it returns nothing (empty String) ? However my source file is $(TargetDir)\$(TargetName).exe – AgentKnopf May 30 '13 at 12:47