How can I pass a Visual Studio project's assembly version to another project for use in a post-build event?
I have a solution with 2 projects:
- My Appli开发者_C百科cation 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.
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>
精彩评论