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

Empty directory is created in Program files if user changes install location #790

Closed
Katara98 opened this issue Dec 23, 2019 · 6 comments
Closed

Comments

@Katara98
Copy link

I have simple project setup like:

var project = new Project(
                              myProduct,
                              new Dir(
                                  Path.Combine(@"%ProgramFiles%", myCompany, myProduct),
                                  new Files("*.*"),
                                  ...);
project.UI = WUI.WixUI_InstallDir;
...

If user changes install location, everything is installed in chosen location, but also empty directory 'C:\Program Files (x86)\myCompany' is created.
Is there some way to prevent creating of this empty directory?

@oleg-shilo
Copy link
Owner

Just from the top of my head. This is what you might be looking for:

AutoElements.SupportEmptyDirectories = CompilerSupportState.Disabled;

@Katara98
Copy link
Author

It didn't help. As I understand, during building the directory 'myCompany' is not actually empty, it contains 'myProduct' directory. It becomes empty during installation, when user changes install directory to custom path

@oleg-shilo
Copy link
Owner

It will need to wait til end of Christmas. But you can have a look at the generated WiX it may give you some clue.

Merry Christmas!

@oleg-shilo
Copy link
Owner

This is an interesting one. That unfortunately does not have a good solution.

   BTW you don't need to use Path.Combine. You are running on Windows only.

This is what WixSharp does for a canonical install scenario <Wix# Samples>\InstallDir):

var project = new Project("My Product",
                  new Dir(@"%ProgramFiles%\My Company\My Product",
                  . . .

produces:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder" Name="ProgramFilesFolder">
    <Directory Id="ProgramFilesFolder.My_Company" Name="My Company">
      <Directory Id="INSTALLDIR" Name="My Product">
      . . .
      </Directory>
    </Directory>
  </Directory>
</Directory>

Understandable if user select a custom destination (sets custom "INSTALLDIR") then My Company is going to be created anyway. But the actual installation files will go nicely to the new location.

Something like that is happening in your case when multiple subdirs are generated and WixSharp assigns INSTALLDIR id to the first parent of the first directory with the file(s).

If you want to avoid that you need to assign INSTALLDIR explicitly. Like this:

var project = new Project("My Product",
                  new Dir("%ProgramFiles%",
                      new InstallDir("My Company",
                          new Dir("My Product",
                          . . .

produces:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder" Name="ProgramFilesFolder">
    <Directory Id="INSTALLDIR" Name="My Company">
      <Directory Id="INSTALLDIR.My_Product" Name="My Product">
        . . .
      </Directory>
    </Directory>
  </Directory>
</Directory>

@Katara98
Copy link
Author

Katara98 commented Jan 6, 2020

It helps, but in that case in dialog where user chooses an install directory default folder would be C:\Program Files (x86)\myCompany, but I want the user to see C:\Program Files (x86)\myCompany\myProduct.

@oleg-shilo
Copy link
Owner

oleg-shilo commented Jan 6, 2020

But this is how MSI/WiX woks. You decide , which point you want to mark as INSTALLDIR and if it happens to have custom dir between programfiles and itself then this dir a what you are asking MSI to install regardless of the user installdir selection (your original situation).

If you have extra custom dirs between your first deployment asset and INSTALLDIR then these dirs are part of your installations (your current situation). Thus if user decided to install on drive D the deployment will go to d:\MyCompany\MyProduct..., which seems to me quite OK.

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

2 participants