I’m learning how to use WiX to create an installer for my projects, and would like to be able to reference my VS2019 C# project’s assembly information as populated from the project’s Properties > Application > Assembly Information button in my .wxs file.
I understand I can use add the project as a reference and then use a $(var.MyProject.???)
declaration, but I have no idea where to find the list of viable dot notation properties for the project. Alternatly I know I can use ” with <Package Manufacturer="$(var.CompanyName)" .../>
to save having to typing the data multiple times, but i’d still prefer to pull it from the project and have it in one place.
Thank you
SEO terms: wix assembly version. wix assembly information
2
Answers
For those who run into this in the future here's what it took to gain access to the assembly information from wix.
Note at the time of posting I hadn't managed to return the entire data object as a single struct, but can at least output the values as strings.
To make it easy to define the targeted assembly file, define a constant either via your node in the .wixproj file Or via the wixProj's Properties > Build > Define Preprocessor variables field:
AssetPath=../MyReferencedProject/bin/$(Configuration)/MyAsset.exe;
Next, place the below code into your .wixProj file. (Edit this with NotePad++ then reload the project in VS)
Finally, in your .wxs file, you can just use:
Refs
Light.exe: See the WiX light.exe documentation here: https://wixtoolset.org/documentation/manual/v3/overview/light.html#standard-binder-variables
If you want to run with the version of your main assembly as the setup’s ProductVersion you should be able to just do:
WiX Sample: Complete Github.com sample here.
The
fileLanguage
andfileVersion
are available for all versioned binaries. Dot NET assemblies support a number of further variables – see documentation (same link as at the top of the answer).Rob Mensching: WiX creator Mensching has an answer here. Essence:
"You can drive your product version off of an assembly's version using "!(bind.assemblyVersion.FileId)". ... You can only specify binder variables in .wxs files. It's a binder (in light.exe) concept not an MSBuild (in MSBuild.exe reading .wixproj files) concept"
Heath Stewart: Please check this blog for some information on .NET assembly values:
https://devblogs.microsoft.com/setup/get-binder-variables-for-assemblies-without-installing-into-the-gac/ – Essence:
"...to get binder variables for assemblies without installing into the GAC set File/@Assembly to “.net” or “win32”, then for the same file set File/@AssemblyApplication to the value for File/@Id"
Links:
preprocessor variables
,localization variables
,etc...
)