Customize Build Events Personalization in Visual Studio

Is there a way to customize the post post event macros, I would like to move the new assembly to a subfolder in the same directory that is specified in the ie assembly version

copy $ (TargetDir) $ (TargetFileName) $ (TargetDir) $ ( ASSEMBLYVERSION ) \ $ (TargetFileName)

However, there is no such macro. Sorting the executable to get this version

call foo.bat $(TargetName)

      

If we have foo.bat evaluate the version of the target by calling the managed application which prints the version of the assembly you are going through, say GetVersion.exe

for /f %%t in ('GetVersion.exe %1') do (
        set _version=%%t
    )
echo %_version%

      

Any ideas? Surely there is a way to set up macros directly?

0


source to share


1 answer


Not sure if this can be done via a post-build script, but you can modify your project file to do the same.

Right-click the project and select Unload Project.

Then right-click it and select "Edit Project".

Now in the project file find the "AfterBuild" target. It's usually at the bottom of the file and commented out.

Uncomment it or just paste the following:



<Target Name="AfterBuild">
  <GetAssemblyIdentity AssemblyFiles="path\to\bin\$(Configuration)\$(OutputName).dll">
    <Output TaskParameter="Assemblies" ItemName="AssemblyVersion"/>
  </GetAssemblyIdentity>

  <Copy 
    SourceFiles="path\to\bin\$(Configuration)\$(OutputName).dll" 
    DestinationFiles="path\to\bin\$(Configuration)\%(AssemblyVersion.Version)\$(OutputName).dll" />
</Target>

      

Finally, right click on the project and choose Update Project.

You may have to fiddle with variable names and possibly create a folder before copying it. Hope this helps.

Idea taken from Automatic Installer Version Numbers for WiX

+1


source







All Articles