Skip to content
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

Question: Creating a dynamic install directory #516

Closed
Chrissyoung1223 opened this issue Oct 25, 2018 · 6 comments
Closed

Question: Creating a dynamic install directory #516

Chrissyoung1223 opened this issue Oct 25, 2018 · 6 comments

Comments

@Chrissyoung1223
Copy link

Chrissyoung1223 commented Oct 25, 2018

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\installertemp\DataAPI\*.*"))); 

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.

@oleg-shilo
Copy link
Owner

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:

var project = new ManagedProject("MyProduct",
                  new InstallDir(@"%ProgramFiles%\My Company\My Product"),        
                      new Dir("DataAPI",
                          new Files(@"E:\Temp\installertemp\DataAPI\*.*"))); 

@Chrissyoung1223
Copy link
Author

Chrissyoung1223 commented Oct 25, 2018

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?

@Xaddan
Copy link
Contributor

Xaddan commented Oct 25, 2018

So correct:

var project = new ManagedProject("MyProduct",
  new InstallDir(@"%ProgramFiles%\My Company\My Product",
    new Dir("DataAPI",
      new Files(@"E:\Temp\installertemp\DataAPI\*.*"))));

@Chrissyoung1223
Copy link
Author

Chrissyoung1223 commented Oct 25, 2018

Thanks @Xaddan i hadn't noticed the difference in brackets at first but this worked great!

@Chrissyoung1223
Copy link
Author

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!

@oleg-shilo
Copy link
Owner

You are very welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants