Giter VIP home page Giter VIP logo

Comments (11)

manytwo avatar manytwo commented on July 24, 2024 1

Thanks for precisons.
So for managed UI, we can't really use UILevel.
To deal with silent install and managed UI, I have found two solutions, I post them here for other users. Please say me if you see somethings bad, or if there is better solution :

1. Custom property

Create a property on project (With deferred for use in Deferred actions)

project.Properties = new Property[] {
      new Property("WixSharp_MANAGED_UI","0"){ IsDeferred = true }
};

Set it to 1 in "project.UIInitialized" Handler, because this handler is not called in silent mode (/quiet)

project.UIInitialized += setupEventArgs => {
                setupEventArgs.Session["wixSharp_MANAGED_UI"] = "1";
 };

Custom properties are usefull to manage multiples values, which can be setted in custom managed UI.

2. Check setupEventArgs.ManagedUIHandle

Simply check if there is a managed UI window or not.

project.Load += setupEventArgs => {
               bool managedSilent = (e.ManagedUIHandle == IntPtr.Zero);
 };

Focus on ManagedAction

When using ManagedAction, must add properties to send as custom data.

project.Actions = new WixSharp.Action[]
         {
                new ElevatedManagedAction(
                      CustomActions.MyAction,
                      Return.check, When.Before, 
                      Step.InstallFiles,
                      Condition.NOT_Installed)
                {
                    UsesProperties = "WixSharp_MANAGED_UI=[WIXSHARP_MANAGED_UI],WIXSHARP_MANAGED_UI_HANDLE=[WIXSHARP_MANAGED_UI_HANDLE]"
                }
       }

Hope it can help someone.
And thanks again for this amazing tools, it make wix easier to understand for me, and save lot of time and efforts!

from wixsharp.

oleg-shilo avatar oleg-shilo commented on July 24, 2024 1

Yes, this is the right way to detect the ManagedUI/EmbeddedUI and silent installs.
Though you don't need to create all this infrastructure (properties) as it's all already done for you. SetupEventsArgs has the required properties created and fully deferred. You only need to analyze these properties at run time:

class SetupEventsArgs
{
    // Gets a value indicating whether this session is started via ManagedUI.
    // Basically it is the answer if the MSI implements native or managed UI
    public bool IsManagedUISession;

    // Gets the ManagedUI window handle.
    // It is set to IntPtr.Zero for silent installs.
    public IntPtr ManagedUIHandle;
...
}

Sorry for not posting the answer early. I just wasn't sure from your original post what was the objective of your effort. I interpret it as the enquiry about the "strange behavior with UILevel" but not as the search for detection of silent installs.

from wixsharp.

oleg-shilo avatar oleg-shilo commented on July 24, 2024

But Load is a direct action right?

This is the right question. You are absolutely right "there is lot of different execution context in MSI engine". During my experiments I found UILevel being incredibly inconsistent and unintuitive for non trivial cases.

For the UI customization MSI offers a special programming model - Embedded UI. According this model a user defined dll/assembly is invoked (via special interface) to display the UI. This is what Wix# ManagededUI is. It's is just a one of possible Embedded UI implementations. One that visually resembles native MSI UI.

For all Embedded UI the native MSI UI is suppressed and its session properties (e.g. UILevel) are managed by MSI in a different way. ManagedUI doesn't alter UILevel (at least intentionally). It just returns the value of the session UILevel property. Thus from Wix# point of view nothing can be done about it. Though, in case of any doubts, you can always access the property directly:

e.Session["UILevel"]

from wixsharp.

manytwo avatar manytwo commented on July 24, 2024

No problem, I consider have help on free or open source projects is bonus, and you responded quickly.
Sorry I didn't really expose my complete goal:

  • I need to make a very specific UI
  • I need to implement different UI modes, all customized : a full UI, a ligthweight one, and silent mode (in one msi setup).
  • Support custom actions with specific steps/conditions.

This is why I tried to use a custom property to set different UI level.
On my first tests, I can't replace ligth standard UI with custom managed one, called with "setup.msi /qr" for example (or I just didn't find how to).

My first idea to deal with it is:

  • Create a managedUi sequence separed in 2 types :
project.ManagedUI.InstallDialogs
                .Add<WelcomeDialog>()
                .Add<SetupTypeDialog>()
                .Add<FeaturesDialog>()
                .Add<InstallDirDialog>()
                .Add<ProgressDialog>()
                .Add<ExitDialog>()

                .Add<LightWelcomeDialog>()
                .Add<LightProgressDialog>()
                .Add<LightExitDialog>()
  • use a property as option ("MANAGED_UI" for the example) for my managed UI level, and /quiet for silent.
  • ManagedUIHandle zero, it is silent install
  • If UI, check MANAGED_UI value in UILoaded, if Light mode go to LightWelcomeDialog
project.UILoaded+= setupEventArgs => {
    if (e.Session["MANAGED_UI"] == "1")
    {
        e.ManagedUIShell.CurrentDialog.Shell.GoTo<LightWelcomeDialog>();
    }
};

It seems to work but again I don't know if there is a easier way to do it or if I should look to different UI type designed for that kind of case.

Sorry the thread is changing of subject.

from wixsharp.

oleg-shilo avatar oleg-shilo commented on July 24, 2024

I see nothing wrong with what you are doing. And I don't thisnk your approach is inappropriate. Since MSI provides you with only one way of creating truly advance UI - Embedded UI and it requires custom state detection. What you are doing is exactly what needs to be done.

Only one minor comment. You can (but don't have to) change the whole UI sequence in your UILoaded handler instead of jumping to the specific dialog:

project.UILoaded+= setupEventArgs => {
    if (e.Session["MANAGED_UI"] == "1")
        e.ManagedUIShell.CurrentDialog.Shell.Dialogs.RemoveAll(d=>d.Name.StartsWith("Light"));
   else
        e.ManagedUIShell.CurrentDialog.Shell.Dialogs.RemoveAll(d=>!d.Name.StartsWith("Light"));
};

Sample CustomUISequence shows the similar technique.

from wixsharp.

manytwo avatar manytwo commented on July 24, 2024

Thanks a lot for all your advices.
I have looked at all UI samples, but I missed this one in ManagedSetup, sorry for the inconvenience.

from wixsharp.

oleg-shilo avatar oleg-shilo commented on July 24, 2024

You are very welcome :)

from wixsharp.

shengxue avatar shengxue commented on July 24, 2024

@oleg-shilo Regarding your above comment:

class SetupEventsArgs
{
    // Gets a value indicating whether this session is started via ManagedUI.
    // Basically it is the answer if the MSI implements native or managed UI
    public bool IsManagedUISession;

    // Gets the ManagedUI window handle.
    // It is set to IntPtr.Zero for silent installs.
    public IntPtr ManagedUIHandle;
...
}

In my test, ManagedUIHandle is IntPtr.Zero even when it is not silent install.

from wixsharp.

oleg-shilo avatar oleg-shilo commented on July 24, 2024

You will need to share your sample. I cannot reproduce it:
image

from wixsharp.

shengxue avatar shengxue commented on July 24, 2024

@oleg-shilo I am using Bundle, so UILoaded is not triggered. My code is like:

        static void Main(string[] args)
        {
            var version = new Version(1, 0, 1, 0);
            var msiPath = BuildMsi(version);
            var bundle = new Bundle(Constants.PRODUCT_NAME,
                new MsiPackage(msiPath) { Compressed = true, Vital = true },
                new ExePackage
                {
                });
      }  
       static string BuildMsi(Version versionToInstall)
        {
            var project = new ManagedProject("My produdct")
            {
                ManagedUI = new ManagedUI(),
                Platform = Platform.x64,
                InstallScope = InstallScope.perMachine
            };

            project.BeforeInstall += project_BeforeInstall;
     }

        static void project_BeforeInstall(SetupEventArgs e)
        {
            MessageBox.Show(e.ManagedUIHandle.ToString());
        }

image

from wixsharp.

oleg-shilo avatar oleg-shilo commented on July 24, 2024

Great. As you code indicates you are using ManagedUI which has no dialogs at all. So there is no handle to it.
I suggest you start with the samples that work and then modify them to your needs.
Alternatively use standard WixSharp VS project templates so your starting solution works.

from wixsharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.