1

When I do a release build of my application I copy all files needed to run the program to a folder. I want that folder name to contain the assembly version.

The build command I have partially works. I can get the version number into a file called tmpfile. The problem seems to be reading the version number from that file into a variable.

if $(ConfigurationName) == Release (
    powershell "(Get-Item -path  $(TargetPath)).VersionInfo.ProductVersion" > tmpfile
    set /p VER=< tmpfile
    echo %VER% > fileversion
    set "DIRNAME=FilterUtilityApp%VER%"
    xcopy /s /y "$(TargetDir)*" "$(SolutionDir)%DIRNAME%\"
    xcopy /y "$(ProjectDir)Docs\*" "$(SolutionDir)%DIRNAME%\Docs\"
)

I have tested the lines where I read and write VER using a CMD window, and the commands work, fileversion contains the version number. When I run the build script, fileversion contains "Echo is on", which I assume means that VER is blank. There may be other problems with my build command, but I am stuck at this point of reading in the version number.

aschipfl
  • 33,626
  • 12
  • 54
  • 99
spainchaud
  • 365
  • 3
  • 12

1 Answers1

1

Based on the comment by aschipfl, here is the working script.

if $(ConfigurationName) == Release (
    SETLOCAL EnableDelayedExpansion
    powershell "(Get-Item -path  $(TargetPath)).VersionInfo.ProductVersion" > version
    set /p VER=< version
    del version
    set "DIRNAME=FilterUtilityApp_!VER!"
    xcopy /s /y "$(TargetDir)*" "$(SolutionDir)!DIRNAME!\"
    xcopy /y "$(ProjectDir)Docs\*" "$(SolutionDir)!DIRNAME!\Docs\"
)

Note that %VER% is replaced by !VER!.

spainchaud
  • 365
  • 3
  • 12