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)
- Add custom wix-WPF dialog via "new item" in Visual Studio HOT 1
- "Per User" installer, AfterInstall is not elevated. HOT 14
- set Wix Toolset version for WixSharp HOT 5
- Duplicate component IDs are added when shortcuts are added HOT 4
- Fonts are not installed for all users HOT 4
- Custom Behavior for "X" button in the title bar HOT 3
- Cannot build .net 8 example project HOT 8
- Tags are wrong in git HOT 2
- "Complete" feature gets added automatically & after installation of MSI, an empty feature folder installed even if it is not selected HOT 14
- installDir variable erased depending on ManagedProject structure HOT 5
- Shortcut "Target" produces unexpected results for many supported WiX environment constants HOT 4
- (Race condition?) Issue with form load order (difficult to reproduce) HOT 5
- > since I know now root cause of my issue, how can I include sub folders in my new Files constructor or somewhere in Files HOT 3
- Dotnet tool should not be relied on for wixsharp. HOT 1
- Info: SFXCA: Failed to create temp directory. Error code 5 HOT 1
- How to execute rollback imeediately If i click on cancel after install execute sequence has started ? HOT 3
- Overview of which SetupEventHandler is fired on which type of project HOT 2
- Wix Woolkit 3.14.1 not working "SFXCA: Failed to create temp directory. Error code 5" HOT 1
- MSI build is failing with failed to add file - Even path is available HOT 7
- How to see in WixSharp project which Wix toolkit version is being used AFTER it has been created? HOT 3
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.