Skip to content

Conversation

@gpduck
Copy link
Contributor

@gpduck gpduck commented Feb 3, 2018

PR Summary

Moves the working directory script to execute during the elevated portion of the install process to prevent access denied errors during install.

Fixes #6095

PR Checklist

Note: Please mark anything not applicable to this PR NA.

<CustomAction Id="SaveShortcutPath" Property="ShortcutPath" Value="[$ApplicationProgramsMenuShortcut]$(var.ProductSemanticVersionWithNameAndOptionalArchitecture).lnk" />
<CustomAction Id="FixShortcutWorkingDirectory" Script="vbscript" HideTarget="no" Impersonate="no">
shortcutPath = Session.Property("ShortcutPath")
<CustomAction Id="SaveShortcutPath" Property="FixShortcutWorkingDirectory" Value="[$ApplicationProgramsMenuShortcut]$(var.ProductSemanticVersionWithNameAndOptionalArchitecture).lnk" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need rename ShortcutPath to FixShortcutWorkingDirectory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property name must match the ID of the custom action in order to populate CustomActionData.

https://stackoverflow.com/questions/11233267/how-to-pass-customactiondata-to-a-customaction-using-wix

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarify! It is not obvious. Please add the comment with the link.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that WiX is not self-explanatory or intuitive to learn but do we really need to document basic WiX stuff here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somebody can change the name. We haven't msi package tests. So I'd prefer a protective comment.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I'd use SetShortcutWorkingDirectory name.

@iSazonov iSazonov self-assigned this Feb 4, 2018
@SteveL-MSFT
Copy link
Member

cc @bergmeister

@bergmeister
Copy link
Contributor

bergmeister commented Feb 5, 2018

I have tested this works when run via GUI or quiet install. However, I have some comments about the code:

  • The custom actions could also have a Return="check" attribute that inspects the exit code and would make the installer fail in case there is a problem. I will leave this decision up to you @SteveL-MSFT

<Custom Action="SaveShortcutPath" After="InstallFinalize" />
<Custom Action="FixShortcutWorkingDirectory" After="SaveShortcutPath">
<Custom Action="SaveShortcutPath" Before="FixShortcutWorkingDirectory" />
<Custom Action="FixShortcutWorkingDirectory" Before="InstallFinalize">
Copy link
Contributor

@bergmeister bergmeister Feb 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this style hard to read/maintain. It should be OK to run it e.g. just after InstallFiles and would make it more readable:

<Custom Action="SaveShortcutPath" After="InstallFiles" />
<Custom Action="FixShortcutWorkingDirectory" After="SaveShortcutPath">
```
This is just personal preference, so feel free to interpret it how you like (i.e. this is not a 'you must do')

@bergmeister bergmeister mentioned this pull request Feb 5, 2018
9 tasks
@SteveL-MSFT
Copy link
Member

@bergmeister agree that we should leverage the exit code check and fail the install

@TravisEz13
Copy link
Member

I think the exit code check should be a separate issue. There are many things to consider, such as what is Windows Script Host is disabled

Copy link
Member

@TravisEz13 TravisEz13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use SetShortcutWorkingDirectory for the name of the script custom action

@iSazonov
Copy link
Collaborator

Before the change MSI package fail but not revert (leave already copied files).

@TravisEz13
Copy link
Member

TravisEz13 commented Feb 12, 2018

@iSazonov

Before the change MSI package fail but not revert (leave already copied files).

Are you saying after this change, if the script fails the package fails?

If so, perhaps we should revert this. Scripts can be unreliable and making it a critical part of the package doesn't seem like a good idea.

@iSazonov
Copy link
Collaborator

We cannot predict what will cause the installer to crash. We can only confidently say that our installer will be enhanced in the future and such crash reasons will become more.

In any case, we need to think about implementing rollback action. Sample https://medium.com/@thehenrytsai/uninstall-vs-rollback-custom-action-in-wix-beed702d45c1

@TravisEz13
Copy link
Member

We can predict it. Script actions have a high historical failure rate due to factors unrelated to the script

@gpduck
Copy link
Contributor Author

gpduck commented Feb 13, 2018

So based on my research, the options are:

  1. WSH based script
  2. Custom action as C# plugin wrapping COM components for editing shortcuts
  3. Manually create shortcut (which would probably be a custom plugin)

I'm open to other suggestions as well?

@bergmeister
Copy link
Contributor

bergmeister commented Feb 13, 2018

First of all, I think we should revert commit 795c61125a531d62784e299a3159844b733e8a91 in the meantime (that's what source control is for), especially given the upcoming pre-release next week on 2/22.
My opinion on error handling (and I came up to this conclusion after thinking of the similar problem that I have with Enable-PSRemoting in my current PR 5999)

  • If the successful execution of an installer script is critical and if the failure messes up the installation, then the error code must be respected and the installation should fail (and also rollback the custom action if required)
  • If the execution of an installer script is optional and a failure has no effect on the installation apart from the fact that the optional feature could not be installed, then not returning the exit code and continuing the install makes sense. An informal message is nice to have but hard to achieve because it requires stuff like e.g. C# based custom actions.
    Let me know what you think.

About the specific problem: although it's hard to bootstrap custom C# actions the first time, I think they would be very welcome and helpful for future installer features (like e.g. PR 5999)

@iSazonov
Copy link
Collaborator

I don't think plugin custom actions are more reliable than scripts. For example, if we lock a system using a GPO or third-party security product, we will get the same installation error. However, if we want an advanced installer, then definitely we should stick to one way of creating extensions and handling errors and I believe it will be C#. In this case, we must also have the installation tests.

I think that first we need to define our strategy.
If we are very conservative, it will require minimal effort.
If we want to make the installer very advanced, it will require a lot of development and support costs. I'm not sure this is urgently needed right now. I would postpone this until the transition to .Net Core 2.1 version that might require important changes to our installation packages for all platforms.

@TravisEz13
Copy link
Member

@bergmeister @iSazonov
I agree with @bergmeister about

  1. reverting the previous commit
  2. the general description of how robust the custom action will be.
  3. that optional custom actions should be implemented as a compiled custom action
  4. a C# based custom action infrastructure would be good to have (as long as it can be dotnet core based)

@bergmeister
Copy link
Contributor

bergmeister commented Feb 20, 2018

@TravisEz13 Commit 795c61125a531d62784e299a3159844b733e8a91 is still not reverted. Is someone stuck inside vim? 😜
https://stackoverflow.blog/2017/05/23/stack-overflow-helping-one-million-developers-exit-vim/

@TravisEz13
Copy link
Member

#6203 has been submitted

@iSazonov
Copy link
Collaborator

@gpduck Please resolve merge conflicts.

@stale
Copy link

stale bot commented Mar 26, 2018

This PR has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs within 10 days. Thank you for your contributions.

@stale stale bot added the Stale label Mar 26, 2018
@TravisEz13
Copy link
Member

I think we can close this for now. See #6099 (comment)

@TravisEz13 TravisEz13 closed this Mar 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vbscript in MSI fails

5 participants