1

I have a solution with 2 projects:

  • My Application 1.2.54 (C# WinForms)
  • My Application Setup 1.0.0.0 (WiX Setup)

I would like to add a post-build event to the WiX Setup project to run a batch file and pass it a command line parameter of My Application's assembly version number. The code may look something like this:

CALL MyBatchFile.bat "$(fileVersion.ProductVersion($(var.My Application.TargetPath)))"

But this results in the following error:

Unhandled Exception:The expression """.My Application" cannot be evaluated. Method 'System.String.My Application' not found. C:\My Application\My Application Setup\My Application Setup.wixproj

Error: The expression """.My Application" cannot be evaluated. Method 'System.String.My Application' not found. C:\My Application\My Application Setup\My Application Setup.wixproj

I would like to be able to pass "1.2.54" to MyBatchFile.bat somehow.

Coder7862396
  • 415
  • 1
  • 6
  • 13

1 Answers1

2

In your Wix project file (*.wixproj) override the AfterBuild target to call your batch file :

<Target Name="AfterBuild">
  <!-- Get "My Application" assembly version -->
  <GetAssemblyIdentity AssemblyFiles="../my_assembly_dir/MyAssembly.dll">
    <Output TaskParameter="Assemblies" ItemName="AssemblyIdentity"/>
  </GetAssemblyIdentity>

  <Exec Command="MyBatchFile.bat %(AssemblyIdentity.Version)"/>
</Target>
Julien Hoarau
  • 48,964
  • 20
  • 128
  • 117