I have this little piece of codes:
```c#
class Program
{
const string Manufacturer = "AwesomeCompany";
const string ProductName = "AwesomeProduct";
static readonly Version Version = new Version("1.0.0");
static void Main(string[] args)
{
var project = new ManagedProject(ProductName);
project.OutFileName = $"msi-{Version}";
project.PreserveTempFiles = true;
project.InstallScope = InstallScope.perMachine;
project.UpgradeCode = new Guid("89d8e4db-8703-4273-9f96-19206e7a5037");
project.MajorUpgrade = MajorUpgrade.Default;
project.ProductId = Guid.NewGuid();
project.Version = Version;
project.AddDirs(
new Dir("ProgramFilesFolder",
new Dir(Manufacturer,
new InstallDir(ProductName))));
project.Load += e =>
{
if (e.Mode == SetupEventArgs.SetupMode.Installing)
{
// Assertion failed during installation with bundle.
Debug.Assert(!string.IsNullOrEmpty(e.InstallDir), $"'{nameof(e.InstallDir)}' cannot be NULL or empty.");
}
};
var msiPath = Compiler.BuildMsi(project);
var bootstrapper = new Bundle(ProductName);
bootstrapper.OutFileName = $"bundle-{Version}";
bootstrapper.PreserveTempFiles = true;
bootstrapper.UpgradeCode = new Guid("0f86ca33-a015-43c5-871c-d7b72606886d");
bootstrapper.Version = Version;
bootstrapper.Chain.Add(new MsiPackage(msiPath));
Compiler.Build(bootstrapper);
}
}
``
Once executed, both .msi and .exe installer are built. However,SetupEventArgs.InstallDir` is empty when I start the installation from .exe installer. When using the .msi installer (which is the exact same msi bundled into the bootstrapper), the issue does not occured.
Thoughts?
Can you just check install dir directly from property with e.Session.Property("INSTALLDIR").
If it works then it is WixSharp who is failing to tunnel this value to the property.
If it doesn't work then... well let's see if it does :)
Can you just check install dir directly from property with
e.Session.Property("INSTALLDIR").
Just double checked, e.Session.Property("INSTALLDIR") is empty when I start the installation from .exe installer. That's not the case when using the .msi installer.
This is what I was afraid of.
It may mean that bootstrapper runtime does not handle this property correctly. Meaning that the solution would be not in WixSharp but rather in Burn area.
I am really puzzled about it as if you pass INSTALLDIR via Bootstrapper it ends up in your MSI properties correctly. Not sure what is happening in this case :o(
Meaning that the solution would be not in WixSharp but rather in Burn area.
I'm afraid that's the case.
My temporary workaround to this is by manually set the INSTALLDIR from bootstrapper application so that it is available when ManagedProject.Load is triggered. Also, I notice that INSTALLDIR will get updated to actual value later at ManagedProject.AfterInstall (overwriting my value set from bootstrapper application).
Maybe Burn engine overwrite the MSI properties on startup, and then the actual value got recovered during MSI session? Just my wild guess as I'm not really familiar with WiX 馃槄.
Hallo. I had same problem in my installer BA. i found https://stackoverflow.com/questions/27668820/wix-how-to-allow-user-to-change-install-location-on-bootstrapper on Stackoverflow.
After test it on VM , somehow it works. Do the BA set Properties of MSI by Name or why passing same name of BA , works somehow?
Code:
create Property in msi file creation like
...
new Property("INSTALLFOLDER", "[Installfolder]")
...
then add same name in BA as Variables = "Installfolder".ToStringVariables();
somehow BA overwrite at time of installation installdir by the same name.
seems there is no progress in solving this WiX/Burn mystery