How to get full install directory path #1627
Replies: 2 comments
-
For now, I am using this workaround, but it produces a warning from Wix about how the StandardDirectory Element should be used rather than hard-coding the ProgramFiles path: Feature binaries = new Feature($"{Options["ProductName"]} Application", "Main Application Files");
string programFiles = Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%");
string installPath = $@"{programFiles}\{config.Manufacturer}\{Options["ProductName"]}";
// Build a WixSharp project
var project = new ManagedProject(Options["ProductName"],
new Dir(installPath,
new File(new Id("application_exe"), binaries,
$@"{Options["ArtifactPublishDirectoryPath"]}/{Options["ProductName"]}.exe",
new FileShortcut(binaries, Options["ProductName"], "%ProgramMenu%"),
new FileShortcut(binaries, Options["ProductName"], "%Desktop%")
),
new File(new Id("application_icon"), binaries,
config.ProductIconFile.FullName
),
new Files(binaries, $"{Options["ArtifactPublishDirectoryPath"]}/*.*",
f => !f.EndsWith(".pdb") && !f.EndsWith($"{Options["ProductName"]}.exe"))
),
new Binary(new Id("License"), config.LicenseFile.FullName)
)
// Snipped |
Beta Was this translation helpful? Give feedback.
-
I am afraid it is the area where you are trading the stability in some edge cases for flexibility. If I were you I would try to understand how serious the warning is. Sometimes WiX warnings can be safely ignored, but more often they do indicate the potential impact. And it is your decision about how acceptable this impact is.
Correct. Unfortunately, the registry key value can only have the path to the icon file on the target system so it cannot use the icon resource embedded in a binary. |
Beta Was this translation helpful? Give feedback.
-
Hello again,
After I recently discovered that using the EnableUninstallFullUI() does not use the MSI's ARPPRODUCTICON property, I learned that EnableUninstallFullUI() allows the user to pass in the path to an icon to use for the uninstaller in Add/Remove Programs. (Btw, this was really not obvious to me.)
If I provide a full path to the ico file, it works fine on my machine (TM). However, when we execute it in our build pipeline, the path breaks. I determined that this is because the Uninstaller is relying on a registry key to define the full path to the icon file. This is different than the usual MSI-binary in the Icon table.
My question is: how can I have my installer automatically predict the location of an .ico file that I am installing (I have added a File() entry to my Project, with an Id("application_icon") so that it gets installed into Program Files with the application)?
I need a way to provide the path that the ico file gets installed to, so that the Uninstaller can use the icon on any system and we can build it in our build pipelines.
So far, I've been poking around the Project and Dir objects, but I'm not seeing an obvious and deterministic way of getting the path.
When I try to use a path like "%ProgramFiles%...", it doesn't actually work. I am assuming that the Uninstaller does not parse the %variables% the way that Wix or MSI do.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions