I am having trouble with with my directories, I want my InstallDir to be my top parent directory and for any other Dir to be contained within this folder structure. I have tried this multiple ways and can't seem to work it out but what I am aiming for is to be able to use the installDirDialog to change the install location. The directory left unchanged installs correctly, but if i was to change the install location it only builds the new folder structure and the files install install to the default location. I know why it's installing to this location because its referencing a static string, I only used the below as an example to simplify the problem I am having.
```
string dirs = @"%ProgramFiles%\My Company\My Product";
var project = new ManagedProject("MyProduct",
new InstallDir(dirs),
new Dir(dirs + @"DataAPI",
new Files(@"E:\Temp\installertempDataAPI*.*")));
Another approach was to use an MSI property and set that as the install path.
public class General
{
public static string Product = "PRODUCT";
public static string InstallLocation = "INSTALLDIRECTORY";
}
``
In setup.cs
string dirs =General.InstallLocation;`
I then set this property in the install dialog.
MsiRuntime.Session[General.InstallLocation] = installDir.Text;
This didn't work either and only passed INSTALLDIRECTORY as the path.
Have a look at "Install Files" and "InstallDir" samples. but from the top of my head you have some problems with your dir structure. Try change it to something like this:
C#
var project = new ManagedProject("MyProduct",
new InstallDir(@"%ProgramFiles%\My Company\My Product"),
new Dir("DataAPI",
new Files(@"E:\Temp\installertemp\DataAPI\*.*")));
Thanks for quick reply I will have a look at the code samples you reccomended but i tried your above suggestion, here is the log output, its installing the folder structure for installDir but placing my dataAPI folder and its containing files at the base of my E drive.
ActionStart: Action 13:39:48: CreateFolders. Creating folders
ActionData: Folder: C:\Program Files (x86)\My Company\My Product\
ActionData: Folder: C:\Program Files (x86)\My Company\
ActionStart: Action 13:39:48: InstallFiles. Copying new files
ActionData: File: Antlr3.Runtime.dll, Directory: E:DataAPI\bin\, Size: 102912
Is it possible to access the MsiRuntime.Session[installLocation] in the setup class where the installer is built?
So correct:
C#
var project = new ManagedProject("MyProduct",
new InstallDir(@"%ProgramFiles%\My Company\My Product",
new Dir("DataAPI",
new Files(@"E:\Temp\installertemp\DataAPI\*.*"))));
Thanks @Xaddan i hadn't noticed the difference in brackets at first but this worked great!
Also @oleg-shilo i really can't thank you and all those that have contributed to Wixsharp enough! As someone who has never used wix before and seeing the horrible mess it is, Wixsharp has really saved me!
You are very welcome :)
Most helpful comment
So correct:
C# var project = new ManagedProject("MyProduct", new InstallDir(@"%ProgramFiles%\My Company\My Product", new Dir("DataAPI", new Files(@"E:\Temp\installertemp\DataAPI\*.*"))));