-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Property conditional installation with bootstrapper #1746
Comments
morning, No, you can't directly use a property set in the bootstrapper (managed UI) for file conditions in the MSI because the MSI session and bootstrapper session are separate. The MSI only knows properties passed to it at launch. bootstrapper.MsiProperties = new[] { "MY_CUSTOM_PROPERTY=[BootstrapperApplicationData]" }; Alterative project.Properties = new[] { new Property("MY_PROPERTY", "StoredValue") }; Then, retrieve it inside your MSI: session["MY_PROPERTY"]; For your case (500 files and 10 properties), you might consider dynamically generating the installation conditions in the build step, storing them in an external file, and having the bootstrapper read and set the properties before launching the MSI. It not trivial Task as well. I dont tested it, may this helps you. |
Thank you for your quick response. If I understand correctly, when the bootstrapper initializes the MSI, it can pass the properties stored in the bootstrapper to the MSI? My project is for an installer on different machines. I have already created a script that dynamically includes the files in the installer with the conditions. The conditions are defined during the execution of the installer based on the detected type of machine and the machine's version. |
Yes. BUT is one way , from BA to MSI, not backwards. You cant reflect msi to BA back. |
Okay! 🙃 So how can I get some information (like different machine configurations included in the MSI) inside the bootstrapper? Is it possible to use a JSON file, generated during the build process, included in the EXE, and read the file during the installation directly from the EXE? |
MSI has custom Action where you can do almost everthing in C# code. Remember whole process is controlling by msiexec aka windows installer not BA . BA is ui over msi, because msi has limited or almost nothing , support for multiple instances or installers msi packages. Here comes BA with payloads and all addtionally stuff. BA tunneling all data from exe to msi and msi DO installjob, not exe. |
Mind you |
Thanks, guys, for your fast response! I finally managed to set properties inside the MSI from the custom Bootstrapper Application. Here is the updated part of the code: On bootstrapper buildsetup.cs var bootstrapper =
new Bundle(
"MyProduct2",
new MsiPackage(productMsi)
{
Id = "msiPackage",
DisplayInternalUI = true,
MsiProperties =
"MY_PROPERTY=[MY_PROPERTY];MY_PROPERTY2=[MY_PROPERTY2]"
}); During executionMainWindow.xaml.cs bootstrapper.Engine.SetVariableString("MY_PROPERTY", "A", false);
bootstrapper.Engine.SetVariableString("MY_PROPERTY2", "Hello world", false); Regarding the JSON file, it was just a suggestion for passing a simple config file from the build part to the execution part. I could also use a simple text file, ... |
One last question before closing the issue. I'm having trouble passing the configuration file from the build phase to the execution phase. Do you have any recommendations on how to accomplish this? Is it possible to set a property during the build that I can access during execution using bootstrapper.Engine.GetVariableString("PROPERTY_NAME")? Alternatively, how can I include my file during the build process and access it during installation without actually installing it? |
you can try to add your file as ressource and write it as byte[] stream to temp file at starttime. example code string tempFilePath = Path.Combine(Path.GetTempPath(), "config.xml");
string resourceName = "Yournamespace.Filename.xml";
// Read Stream from embeded Ressource
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
{
if (stream == null)
{
return;
}
// Write in Temp-Path
using (FileStream fileStream = new FileStream(tempFilePath, FileMode.Create, FileAccess.Write))
{
stream.CopyTo(fileStream);
}
} you can also add line into Bootstrapper Application bootstrapper.MsiProperties = new[] { "CONFIG_FILE=" + tempFilePath }; in msi later read file with in your step. session["CONFIG_FILE"] = whatever you want. |
Hi,
Thanks for this project.
I want to perform a conditional installation using File condition with a property inside a custom UI managed by a bootstrapper application. Is it possible to do that? If not, how could I achieve it?
Can I store some data inside the property at the build step and retrieve this data at the beginning of the installer application? If not, how can I pass some data from the build step to the execution step without hardcoding the information?
This program is a test. In reality, I have 500 files with different installation conditions for each file, depending on 10 properties.
Main program
Custom bootstrapper application
View execution
The text was updated successfully, but these errors were encountered: