Closed dorlep closed 4 months ago
In the Msi_AfterInstall
you can get the installdir from the args: e.InstallDir
Thus by combining it with the feature path you can get the exact dir:
var path = e.InstallDir.PathCombine("FEATURE_INSTALL_PATH2");
. . .
Unrelated. You may improve the readability of your code if you include it in the code section. It's not obvious so sharing it with you: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks
I have fixed your message above.
Hi oleg-shilo,
Not getting the correct path, I am getting path like "C:\Temp\xyz\FEATURE_INSTALL_PATH2" which is like combine 1st feature path and then ID. Even I am getting only 1st feature path using e.InstallDir . How can I get the other features path as my all features are installed in different location (like one is on F drive and one is on c drive, parent dir is not same).
Sorry. There are two problems with the code I suggested:
I meant to resolve the FEATURE_INSTALL_PATH2
property with the session object. I got confused with what that string was in your code.
And also... InstallDir is unnecessary in the code I shared. The whole property/dirId is set by the MSI to the complete absolute path.
This is the code you need to use. I checked it. It works:
project.DefaultDeferredProperties += ",FEATURE_INSTALL_PATH2";
project.AfterInstall += (SetupEventArgs e) =>
{
try
{
MessageBox.Show(e.Session.Property("FEATURE_INSTALL_PATH2"));
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
};
And...
Note, project.DefaultDeferredProperties += ",FEATURE_INSTALL_PATH2";
without it, the AfterInstall
cannot access this property as it is executed as deferred action and can only access deferred props.
Don't ask, it is one of those black magic MSI cases.
It is working. Thank you so much for your help :)
My Msi is installing features in separate folders and during uninstall I wanted to delete all the folders. How can I get the path of each features where that feature has installed in Msi_AfterInstall event, so that I can delete it Programmatically. Below is my code to create project
Please help me. Thank you in advance.