Quantcast
Channel: wixsharp Discussions Rss Feed
Viewing all 1354 articles
Browse latest View live

New Post: How to add preprocessor tags?

$
0
0
You can use WixSharp.Entity extension method AddXmlInclude:
project.AddXmlInclude("CommonProperies.wxi")
       .AddXmlInclude("CommonProperies2.wxi");
Have a look at InjectXML sample.
Note that the placement of the include is controlled by the nature of the Entity the include is attached to. Thus
new File("Source="Files\Docs\Manual.txt").AddXmlInclude("FileCommonProperies.wxi")
Will produce the following wxs code:
<FileId="Manual.txt"Source="Files\Docs\Manual.txt"><?include CommonProperies.wxi?>
</File>

New Post: Absolute path

$
0
0
ManagedUI InstallDirDialog doesn't resolve the special value of the INSTALL dir at startup. This is due to the fact that special custom scheduled for that purpose is not executed yet.

Indeed it is a problem and I logged the issue on your behalf.

The problem is now corrected and you can get the latest beta release (v1.0.28.5) from NuGet
PM> Install-Package WixSharp.bin -Pre

New Post: Absolute path

New Post: ManagedUI issue: A callback was made on a garbage collected delegate

$
0
0
I use ManagedUI and have an exception at the end of the installation process:
Managed Debugging Assistant 'CallbackOnCollectedDelegate' has detected a problem in '...WpfSetup\bin\Release\WpfSetup.exe'.

Additional information: A callback was made on a garbage collected delegate of type 'WixSharp.Msi!WindowsInstaller.MsiInstallUIHandler::Invoke'. This may cause application crashes, corruption and data loss. When passing delegates to unmanaged code, they must be kept alive by the managed application until it is guaranteed that they will never be called.
In WixSharp.Msi\MsiSession.cs I see this:
             uiHandler = new MsiInstallUIHandler(OnExternalUI); //must be kept alive until the end of the MsiInstallProduct call
where OnExternalUI is a private function.
Check this topic also: http://stackoverflow.com/questions/7302045/callback-delegates-being-collected
You are creating a delegate object here and passing it to the unmanaged code. Problem is, the garbage collector cannot track references held by native code. The next garbage collection will find no references to the object and collect it.
Also it's working fine if I use Debug version of WixSharp.Msi (because of it's not optimized).

New Post: ManagedUI issue: A callback was made on a garbage collected delegate

$
0
0
Great thank you for reporting. This is an interesting one.

>OnExternalUI is a private function.
Actually the fact that it is private is irrelevant as GC doesn't discriminate on the base of the visibility type. And it is not OnExternalUI but uiHandler who get's collected. But it is not where problem is anyway.

You probably noticed my second comment:
finally
{
    ...
    //It is important to reference uiHandler here to keep it alive till the end. //The debug build is more forgiving and referencing uiHandler is not essential as the code is not optimizedif (uiHandler != null)
        uiHandler = null;
}
This work around was done to keep the uiHandler reference alive until the end of the method call. Exactly in the spirit of the stack overflow post you provided. However... To my surprise in the finally scenario the trick is invalidated. Somehow finally screws JIT and the condition for uiHandler is never executed.

Interestingly enough it is not because of the compiler optimization. Reflector clearly shows that the cal wasn't removed:
Image
But the debugger never visits the line with the condition, meaning that it is JIT who does the damage. It's worth to note that moving the condition below the finally clause restores the power of the work around even though the finally clause scope is not changed in this case:
finally
{
    ...
}

if (uiHandler != null)
    uiHandler = null;
Anyway it is enough to put any meaningful invoke inside of the condition to fool JIT.
if (uiHandler != null)
{
    Environment.SetEnvironmentVariable("ReasonForThis", "IHadToDoSomethingThatJITWouldNotOptimise");
    uiHandler = null;
}
The fix has been committed and will be available with the next release (in a day or so).

Thank you for your feedback.

New Post: Passing user data to after_install

$
0
0
Hi all,
I have managed setup with one custom dialog.(I'm asking user for some data (IP address, actually)). Using MsiRuntime.Session["IPADDRESS"] for storing user input.
I'm using Custom UI Dialog from samples as basis.
After installation a want to edit some files in INSTALLDIR, adding this user data to config files ...
project.AfterInstall += project_AfterInstall;
and in project_AfterInstall(SetupEventArgs e) i'm trying to edit config files.
When I tried to use e.session["IPADDRESS"] i get an exception "Cannot access session details from non immediate custom action"

So my question is how to pass this user input to AfterInstall func?
Or please point me to right place in documentation..

Thank you!

New Post: Passing user data to after_install

$
0
0
The problem is caused by the MSI limitation, which prevents user from accessing ANY property from the deferred custom actions (e.g. project.AfterInstall) due to the Session object being already disconnected.

Fortunately there is a work around - CustomActionData. It is a "sacred" place where copies of the properties can be placed by specially crafted property packing custom action. Wix# allows doing all with a single line of code. You just have to nominate (with DefaultDeferredProperties) what property needs to be tunneled to the Project.AfterInstall event handler. This is a fragment for the CustomUIDialog sample:
//if the property 'PASSWORD' is not preserved as deferred then it will not be available //from the Project_AfterInstall, which is a deferred custom action.
project.DefaultDeferredProperties += ",PASSWORD"; 
...
staticvoid Project_AfterInstall(SetupEventArgs e)
{
    if (e.IsInstalling)
        MessageBox.Show($"User '{Defaults.UserName}' with password '{e.Session.Property("PASSWORD")}' has been created");
}
Note that I am using e.Session.Property("PASSWORD") instead of e.Session["PASSWORD"]. This is because the session object is disconnected and contains no data. However the extension method Property() transparently accesses data either form Session or Session.CustomActionData depending which one is available.

New Post: Passing user data to after_install

$
0
0
BTW in the very latest release v1.0.29.0 you can use new field IsDeferred:
new Property("PASSWORD", "pwd123") { IsDeferred = true })
It has the same effect as
project.DefaultDeferredProperties += ",PASSWORD"; 

New Post: How to create shortcut in program menu for all users?

$
0
0
How to create shortcut in program menu for all users (Environment.SpecialFolder.Programs)?

New Post: Passing user data to after_install

New Post: Absolute path

$
0
0
I suppose one bug is still persists. I think it connected to this problem so I won't start new thread..
project.BeforeInstall += msi_BeforeInstall;
in msi_BeforeInstall function e.InstallDir and e.Session["INSTALLDIR"] resolve as "C:\ABSOLUTEPATH" while trying to uninstall.

Thanks for helping..

New Post: wixsharp setup.exe code -532462766

$
0
0
Sometimes I get this compilation error code

-532462766

What does that mean and where can find the compilation/linking error?

New Post: wixsharp setup.exe code -532462766

$
0
0
Most likely it is the result of the exception in the user code.

This is what happens when you build WixSharp in VS:
  1. VS builds your assembly (projects executable)
  2. VS runs WixSharp.targets from the NuGet package:
<Exec Command="&quot;$(TargetPath)&quot; &quot;/MBSBUILD:$(ProjectName)&quot;" WorkingDirectory="$(ProjectDir)"/>
As the result your assembly gets executed and if it doesn't exit cleanly then VS returns a failure exit code (e.g. -532462766) assumed by VS/OS. The code itself has no meaning for the user as usually the assembly entry point routine doesn't control exit code at all:
staticvoid Main()
{
    ...     
    project.BuildMsi();
}
However if any WiX error is encountered then it is caught by BuildMsi and printed in the VS output window. On the other hand if it is the user code raises the unhanded exception then the error info is lost. If it is the case then you can easily fix this by putting your Main implementation in the try-catch or better yet place Debugger.Launch at the start and you will be able to see the error under debugger.

New Post: How to create shortcut in program menu for all users?

$
0
0
Have you had a look at 'AllInOne', 'Shortcuts' and 'Shortcuts-2' samples?
The choice of "for all users" or "for current user" will depend on the installation type (new Property("ALLUSERS", "1"),).
I think 'Shortcuts-2' does exactly what you want.

New Post: Absolute path

$
0
0
Thanks. Yes the fix only covered ManagedUI dialog scenario but not BeforeInstall.
Resolving absolute INSTALLDIR for managed events (outside of ManageUI) was scheduled at CostFinanlize and it is too late for BeforeInstall. I have changed the code to scheduled resolving absolute path before.AppSearch and it seems to address problem.

You can get the HotFix build v1.0.29.1 from NuGet
PM> Install-Package WixSharp.bin -Pre

New Post: How to create shortcut in program menu for all users?

$
0
0
Thank you. It solved the problem.

New Post: Rollback custom action after pressing Cancel button

$
0
0
Hi,

I have a rollback custom action which is not executed in case of a rollback caused by pressing the Cancel button.
The rollback custom action is defined between InstallInititialize and InstallFinalize actions.
I get the message:
MSI (s) (34:30) [14:34:27:181]: Invoking remote custom action. DLL: C:\WINDOWS\Installer\MSI9D2C.tmp, Entrypoint: RollbackUpdateDatabase
SFXCA: Extracting custom action to temporary directory: C:\WINDOWS\Installer\MSI9D2C.tmp-\
SFXCA: Binding to CLR version v4.0.30319
Calling custom action CustomActions.RollbackUpdateDatabase
Exception while loading custom action:
Action14_RollbackUpdateDatabase returned actual error code 1603 but will be translated to success due to continue marking
I mention that I tried to set Impersonate property on rollback custom action to both values: true and false, with the same bad result.

Any ideea why the rollback custom action did not run when pressing Cancel button during install?

New Post: Problems with BackgroundImage and BannerImage

$
0
0
Hi,

i have some problems with the path of BackgroundImage and BannerImage (WixSharp.1.0.29.0).

I created a new C# console project with VS 2013. Some code lines:
// ...

project.ManagedUI.InstallDialogs.Add(Dialogs.Welcome)
                                .Add(Dialogs.Licence)
                                .Add(Dialogs.InstallDir)
                                .Add(Dialogs.Progress)
                                .Add(Dialogs.Exit);

project.SourceBaseDir = @"C:\Users\Master\Desktop\input"; //Test.exe, readme.txt,...
project.OutDir = @"C:\Users\Master\Desktop\output"; //Test.msi

project.ControlPanelInfo.ProductIcon = @"Resources\icon.ico";
// ...
project.LicenceFile = @"Resources\Licence.rtf"; 
project.BackgroundImage =  @"Resources\SetupDialog.bmp";
project.BannerImage = @"Resources\SetupBanner.bmp";
// ...
project.PreserveTempFiles = true;
The files in the "Resources" folder are included in the VS project (not in SourceBaseDir, OutDir).
My images for the background and banner are not shown in the setup dialog. The license is shown correctly.

I selected the option "Copy to Output Directory: Copy Always" in VS for all files but that does not solve the problem with the BackgroundImage/BannerImage.
After that i copied the "Resources" folder to the input and output directory and built the Test.msi again. But it did not help.

I also tried to set a absolute path:
String pathOfProgram = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(Program)).Location);
project.BannerImage = System.IO.Path.Combine(pathOfProgram, @"Resources\SetupBanner.bmp");
I checked the path in generated *.wxs:
<WixVariable Id="WixUIBannerBmp" Value="C:\Users\Master\Desktop\Test\Test.Setup\bin\Debug\Resources\SetupBanner.bmp" />
...
<Binary Id="WixUI_Bmp_Banner" SourceFile="..\output\Test.dialog_banner.png" />
The path "C:\Users\Master\Desktop\Test\Test.Setup\bin\Debug\Resources\SetupBanner.bmp" is correct. A Test.dialog_banner.png is created in the output folder but it is not my image, it is the default one. hmmm... :-(

Can someone help me?

New Post: Rollback custom action after pressing Cancel button

$
0
0
It seems like it is not a failure in the action itself but rather a problem during with WiX runtime trying to load the custom action (e.g. referenced assemblies are missing).

The easiest way to test it is to have your custom action body completely empty (may be with only a session.Log("something")). If it works then it is a dependency problem and it will need to be fixed by defining the referenced assemblies (e.g. project.DefaultRefAssemblies.Add). Unless of course it is some other dependency problem.

New Post: Registry don't working

Viewing all 1354 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>