For this one, I feel that I am very close. I want to give the user the option of whether to install the shortcut to this program on the Desktop. I am using a ManagedProject.
I see that I can add a Condition to the project thusly:
var project = new ManagedProject( "MyProgram",
new Dir(@"%Desktop%",
new ExeFileShortcut("MyProgram", "{INSTALLDIR]MyProgram.exe", "")
{
Condition = new Condition("INSTALLDESKTOPSHORTCUT=\"YES\"")
{),
new Property("INSTALLDESKTOPSHORTCUT", "YES")
);
and, lo! it does install the Desktop short when I run this installer. And if I set that Property to "NO", it does not.
Now to give the user this option, I created a new Windows.Forms ManagedForm and inserted that into the UI sequence, and that does show up..
project.ManagedUI = new ManagedUI();
project.ManagedUI.InstallDialogs.Add<WelcomeDialog>()
.Add<InstallDirDialog>()
.Add<MyNamespace.UserOptionsDialog()
.Add<ExitDialog>();
(UserOptionsDialog is the one I created).
So question to you is this: How, do I set the value of that Property, from within UserOptionsDialog?
Within any of the event-handlers within UserOptionsDialog, I can set
MsiRuntime.Data["INSTALLDESKTOPSHORTCUT"] = "YES"
for example, but that does not set the Property.
Within your MsiRuntime class, I do not see any Property properties. ?
One other Question: When defining the ExeFileShortcut like this, how do you assign the Icon file to it?
Previously I had added the desktop-shortcut to the project this way:
var desktopShortcut = new FileShortcut("MyProduct", "%Desktop%");
desktopShortcut.IconFile = "App.ico";
project.FileFile((f) => f.Name.EndsWith("MyProduct.exe"))
.First()
.Shortcuts = new[]
{
desktopShortcut,
programMenuShortcut
};
}
and
that did work just fine, plus it put the Icon on the desktop shortcut.
However, when I try to add a Condition to that FileShortcut, when I build it it throws an exception complaining that I should not add a Condition to that.
?
Meantime, thank you for building and sharing this wonderful project -- it is indeed being quite useful to me now.