Comments (11)
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.
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.
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.
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.
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.
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.
You are very welcome :)
from wixsharp.
@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.
You will need to share your sample. I cannot reproduce it:
from wixsharp.
@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());
}
from wixsharp.
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)
- SetVersionFromFileId not working for relative path in Managed Project Dir HOT 3
- Azure pipeline build HOT 4
- If you enter the project name in Chinese, a question mark is displayed on the installation package HOT 6
- WixSharp-wix4.WPF 2.1.2 Can you smoothly upgrade to. NET8 HOT 2
- Install directory path changes when MSI is run second time through msexec command ADDLOCAL parameter HOT 1
- The installation directory value is incorrect HOT 2
- Dialog Data transfer problem HOT 2
- Add Ignore Errors a driver installer to Bundle HOT 1
- Allow specifying the Group name when adding a FirewallException HOT 2
- I would like to set a features directory path by the user in wix# ManagedUI HOT 3
- Execute CA which needed Powershell in Version 5.1 HOT 6
- Is there support for 4 digit version upgrade? HOT 2
- How to debug the installer script using csscript.exe ? HOT 3
- GetResourceBitmap Method is failing resulting in a Null Pointer exception HOT 1
- Unable to set property value from Session Object in a Custom WPF Dialog HOT 4
- Asking for reboot after unistalling HOT 3
- Digital Signature with relative certificate path not working HOT 4
- How to show all installing Files in control , for example userconrol or listbox, in Bundle WPF C# HOT 4
- How to get Features installed path. HOT 3
- dotnet tool install --global wix - Need for all users HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wixsharp.