views:

101

answers:

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.

+1  A: 

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>
madgnome
This worked! Thanks!
Coder7862396