MSI wildcard resolution error
The msi format has a list of wildcards that can be used to target a specific folder inside the computer. For instance, %Desktop% can be used to target the desktop folder of the user executing the .msi
However, there is a bug with the wildcard %PersonalFolder%. While the .msi is executed, the wildcard %PersonalFolder% should be converted into an absolute path to "Documents" folder of the user executing the msi.
- If user Gabriel is executing the msi, the
%PersonalFolder%should be converted to"C:\Users\Gabriel\Documents\"
When I install the .msi, the wildcard %PersonalFolder% is converted into "C:\PersonalFolder\" and not into "C:\Users\[current user]\Documents\"
Notes:
- A list of all msi wildcards can be obtained by:
Compiler.GetMappedWixConstants(true).ForEach(Console.WriteLine); - Wildcard issue confirmed by msi dump:
msiexec.exe /i installKit.msi /L*vx! dump.log
WixSharp.wix.bin v.3.14.0.1 WixSharp.bin v.1.25.2 WixSharpv.1.25.2 Using dotNET 4.6.2
Morning, are you sure there exists EnviromentVariable %PersonalFolder% ? AFAIK there is only %username% which resolved in curent username. If so, you have to add %username% to your msi . EnviromentVariables for personal Document is
Environment.SpecialFolder.MyDocuments
In Samples of Wix# exists Example of EnvVariables. Maybe this can help you.
best regards, Torchok.
Hi, and thank-you for your reply 😉
The C# command WixSharp.Compiler.GetMappedWixConstants(true).ForEach(Console.WriteLine); give this list of strings :
%AdminTools%
%AdminToolsFolder%
%AppData%
%AppDataFolder%
%CommonAppData%
%CommonAppDataFolder%
%CommonFiles%
%CommonFiles64%
%CommonFiles64Folder%
%CommonFilesFolder%
%Desktop%
%DesktopFolder%
%Favorites%
%FavoritesFolder%
%Fonts%
%FontsFolder%
%LocalAppData%
%LocalAppDataFolder%
%MyPictures%
%MyPicturesFolder%
%Personal%
%PersonalFolder%
%ProgramFiles%
%ProgramFiles64%
%ProgramFiles64Folder%
%ProgramFilesFolder%
%ProgramMenu%
%ProgramMenuFolder%
%SendTo%
%SendToFolder%
%StartMenu%
%StartMenuFolder%
%Startup%
%StartupFolder%
%System%
%System16%
%System16Folder%
%System64%
%System64Folder%
%SystemFolder%
%Temp%
%TempFolder%
%Template%
%TemplateFolder%
%Windows%
%WindowsFolder%
%WindowsVolume%
This list of string include %PersonalFolder%, but not %username%. This list of string is compliant with the official list of msi wildards. The official list can be found here, under System Folder Properties : https://learn.microsoft.com/en-us/windows/win32/msi/property-reference
According to Microsoft https://learn.microsoft.com/en-us/windows/win32/msi/personalfolder
%PerfonnalFolder% is a msi wildcard that should be resolved to the full path of the Personal folder for the current user.
I am currently converting InstallShield projects to WIX projects. On the InstallShild part of the equation, %PersonalFolder% do resolve to the full path of the MyDocument folder of the current user and there is no %username% in the msi wildcard viewer.
Note:
- We may have a bit of a semantic issue here. What I call "msi wildcard" is called "MSI System Folder Properties" by Microsoft and seems to be called "EnviromentVariable" on your side.
- I may be able to bypass the issue using the
EnviromentVariable %username%(will test it later), but there still seems to be a wix issue withMSI System Folder Properties %PersonalFolder%
Best regards, Vincent
It looks like a WiX issue.
WixSharp simply converts C# %PersonalFolder% expression into a WiX PersonalFilder Directory Id:
new Dir(@"%PersonalFolder%\\My Product",
new File(@"setup.cs"))
And it does it correctly, as you can see it from this WiX spec for built-in constants: https://wixtoolset.org/docs/v3/bundle/bundle_built_in_variables/
So why it is not deploying in the correct destination is something that is can only be discovered on the WiX side.
Unless.... the WiX XML is not generated correctly because of some WixSharp deficiency. Can you check your WXS file?