How to Combine WIX Setup Project with WIX Bootstrapper Project - c#

I have a WIX Setup Project that includes my custom UI and a WIX Bootstrapper Project that includes prerequsites/dependencies in form of exe and Msi of my projects.
I want to combine them to make a single exe.
If i give reference of my WIX Setup project in Bootstrapper Project then it did not display my WIX UI. However it is able to successfully installed my setup msi and prerequisites.
<Bundle Name="Bootstrapper1" Version="1.0.0.0" Manufacturer="Microsoft" UpgradeCode="4056d930-16b2-44eb-a861-16db566ae44c">
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />
<Chain>
<PackageGroupRef Id="Y"/>
<MsiPackage SourceFile ="$(var.BiodentifySetUp.TargetPath)" Compressed ="yes" />
</Chain>
</Bundle>
<Fragment>
<PackageGroup Id="Y">
<ExePackage Id="Y" DisplayName="software already install"
DownloadUrl="http://download.microsoft.com/download/5/6/2/562A10F9-C9F4-4313-A044-9C94E0A8FAC8/dotNetFx40_Client_x86_x64.exe"
Compressed="no" Cache="yes" PerMachine="yes" Permanent="yes"
Vital="yes" SourceFile=".\y.msi" InstallCommand="/passive /norestart" />
</PackageGroup>
</Fragment>
How can I merge them to make an exe?

what i beleive you want to do is to use single exe to install all dependencies and your own msi and show your own MSI UI when it comes time to install your .msi packageand if I am not wrong with then you simply need to add DisplayInternalUI='yes' to the MsiPackage elements you want to display.
For example:
<Chain>
...
<MsiPackage ... DisplayInternalUI='yes' />
</Chain>
and if it is like you want NO bootstrapper UI but only your MSI UI then there is no such bootstrapper application who will silently install your dependencies and will show your MSI UI.
Please clearly explain your requirement for better responses.

Related

System.Configuration.Install in .NET 6.0

I have a WiX installer and I am looking to move to WiX Toolset 4 using .NET 6.0. Some of the apps we install are written in .NET Framework and there are some Windows Services in there I need to install. I am currently using System.Configuration.Install with the ServiceProcessInstaller class to install/uninstall my services.
If my installer code is in .NET 6.0, is there still a way to install a service using code? I would rather not use sc.exe if it can be helped. We used to do it that way and the ServiceProcessInstaller works much better.
Well, maybe all I needed was the TopShelf.ServiceInstaller package. I forgot I have used this in the past.
You can try the wix toolset and in the Product.wxs file. Following is a snippet. For the detail you can reference my github repo enter link description here
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent"> -->
<!-- TODO: Insert files, registry keys, and other resources here. -->
<!-- </Component> -->
<!-- service registration-->
<Component Id="ProductComponent">
<File Id="WebMvcAppEXE"
Name="WebMvcApp.exe"
DiskId="1"
Source="$(var.WebMvcApp.TargetDir)\WebMvcApp.exe"
Vital="yes"
KeyPath="yes"
/>
<ServiceInstall Id="ServiceInstaller"
Type="ownProcess"
Vital="yes"
Name ="WebMvcAppService"
DisplayName="WebMvcApp Windows Service"
Description="A windows service that host the Web Mvc App."
Start="auto"
Account="LocalSystem"
ErrorControl="normal"/>
<ServiceControl Id="StartService"
Start="install"
Stop="both"
Remove="uninstall"
Name="WebMvcAppService"
Wait="yes"/>
</Component>
</ComponentGroup>
</Fragment>

MSI Installer - conditional installation of prerequisites

I had a problem with SAP Crystal Reports SDK. It disappeared from web, so i had to create my own ClickOnce Bootstrapper package (for that I've used software called Bootstrap generator).
And its almost working as expected, it install SAP Crystal Report before installing main program.
The problem is that it is installing SAP Crystal Report everytime i run installer, even when its already installed.
It looks like my MSI installer doesnt detect that there is already installed version of SAP Crystal Report.
Product.xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Product ProductCode="SAP.Crystal.reports.x86" xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper">
<PackageFiles CopyAllPackageFiles="false">
<PackageFile Name="crruntime_32bit_13_0_15.msi" PublicKey="3082010A0282010100A5F02AFCBAF295DD82C482B0AA83782A08EA007635AFE2E76B57558D6AD708A1C96B86DA81894CDBB42214C26674A5C7F233D8BC76C77B3B2CBC8E38033C3C9C26FC5CD0789A462A2A6B2B19AC9321C851A08544DBF42CE697C97B730964C159D533BA56B835B702AA3F30E96CFD76F60A555EBC862828347E468BF126B9EB345A7E488AEA3451E9E9EB8412A600D1DB811A2C0144697048CD41F100E10AB8225658E1C3B7613A06835E628E2556C0F8BFD1408A0A5FED97892F6B99F49F2F436A0293AA5562FBBD5EE89DC667261E058AA767E168867CEAC2081588C1BD800FC2BFCD98773CEFD3266F54EB0DC7DAF4D5CD1867EA897D39E6A289A4A75ECA890203010001" />
</PackageFiles>
<Commands Reboot="Defer">
<Command PackageFile="crruntime_32bit_13_0_15.msi">
<ExitCodes>
<DefaultExitCode Result="Success" String="Anunexpectedexitcodewasr" FormatMessageFromSystem="true" />
</ExitCodes>
</Command>
</Commands>
</Product>
Package.xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Package Name="DisplayName" Culture="Culture" xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper">
<Strings>
<String Name="Culture">pl</String>
<String Name="DisplayName">SAP Crystal reports x86</String>
<String Name="Anunexpectedexitcodewasr">An unexpected exit code was returned from the installer. The installation failed.</String>
</Strings>
</Package>
Prerequsities properties:
If you want to check if a prerequisite is already installed, you will need to add 2 things to the product.xml file.
First thing is the product code, or registry key.
If you pick a product code you could add an MSI Install check, for example:
<InstallChecks>
<MsiProductCheck Property="CR32BitExists" Product="{9D52DBF3-229A-4723-BF31-C57C9C1D2A23}" />
<MsiProductCheck Property="CR64BitExist" Product="{8055CFEA-3871-4C76-A321-E32F63637CC4}" />
</InstallChecks>
Then you would have to add install conditions, for example (for x86):
<InstallConditions>
<BypassIf Property="CR32BitExists" Compare="ValueEqualTo" Value="1" />
<BypassIf Property="CR32BitExists" Compare="ValueGreaterThanOrEqualTo" Value="3" />
<BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="Intel" />
</InstallConditions>
Notice that CR32BitExists is declared in Install checks and is used in InstallConditions.
About used values (1,3) you can read about here:
https://learn.microsoft.com/en-us/windows/win32/msi/session-featurerequeststate
After modifying product.xml you need to rebuild your msi.
When you try to install it, it will look for mentioned product codes in Install Checks.
If it detects it installed in OS, it will bypass instalation.

How to install a net core application with .NET Core Runtime prerequisite from wix

Since there is no Wix equivalent to Netfx.wixext for .NET Core (i.e. specifying built in Ids to detect and require runtimes), I can't seem to find a way to correctly install .NET Core and also account for various conditions such as a newer version existing in the same version family (i.e. 3.1).
I've tried to utilize the .NET Core installer executable directly in a burn project, but the problem arises that detection only seems to be able to be achieved with Directory or File searches. This results in failing to detect build version differences correctly since I can't detect "3.1.*".
I tried to build a custom action for the Wix Bundle to programmatically detect and set properties based upon installed .NET Core versions -- But of course I realized that Burn bundles cannot have custom actions.
What other options do I have to install runtimes and detect future version of the same .NET Core Family (Major.Minor)?
Here is the snippet of wix code which is relevant:
<?xml version="1.0"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Fragment>
<Variable Name="DotnetCoreRuntime31InstallDir" Value="[ProgramFiles64Folder]dotnet\shared\Microsoft.NETCore.App\3.1.12" />
<util:DirectorySearch Id="DotnetCoreRuntime31Installed" Path="[DotnetCoreRuntime31InstallDir]" Variable="DotnetCoreRuntime31Installed" Result="exists" />
<WixVariable Id="DotnetCoreRuntime31WebDetectCondition" Value="DotnetCoreRuntime31Installed" Overridable="yes" />
<WixVariable Id="DotnetCoreRuntime31WebInstallCondition" Value="" Overridable="yes" />
<Variable Name="AspNetCoreRuntime31InstallDir" Value="[ProgramFiles64Folder]dotnet\shared\Microsoft.AspNetCore.App\3.1.12" />
<util:DirectorySearch Id="AspNetCoreRuntime31Installed" Path="[AspNetCoreRuntime31InstallDir]" Variable="AspNetCoreRuntime31Installed" Result="exists" />
<WixVariable Id="AspNetCoreRuntime31WebDetectCondition" Value="AspNetCoreRuntime31Installed" Overridable="yes" />
<WixVariable Id="AspNetCoreRuntime31WebInstallCondition" Value="" Overridable="yes" />
<PackageGroup Id="AllNetCoreRuntime31">
<ExePackage
Name="dotnet-runtime-3.1.12-win-x64.exe"
SourceFile="Resources\dotnet-runtime-3.1.12-win-x64.exe"
InstallCommand="/install /quiet /norestart /log "[DotnetCoreRuntime31Log]""
RepairCommand="/repair /quiet /norestart /log "[DotnetCoreRuntime31Log]""
UninstallCommand="/uninstall /quiet /norestart /log "[DotnetCoreRuntime31Log]""
PerMachine="yes"
DetectCondition="!(wix.DotnetCoreRuntime31WebDetectCondition)"
InstallCondition="!(wix.DotnetCoreRuntime31WebInstallCondition)"
Vital="yes"
Permanent="yes"
Protocol="burn"
LogPathVariable="DotnetCoreRuntime31Log"
Compressed="yes" />
<ExePackage
Name="aspnetcore-runtime-3.1.12-win-x64.exe"
SourceFile="Resources\aspnetcore-runtime-3.1.12-win-x64.exe"
InstallCommand="/install /quiet /norestart /log "[AspNetCoreRuntime31Log]""
RepairCommand="/repair /quiet /norestart /log "[AspNetCoreRuntime31Log]""
UninstallCommand="/uninstall /quiet /norestart /log "[AspNetCoreRuntime31Log]""
PerMachine="yes"
DetectCondition="!(wix.AspNetCoreRuntime31WebDetectCondition)"
InstallCondition="!(wix.AspNetCoreRuntime31WebInstallCondition)"
Vital="yes"
Permanent="yes"
Protocol="burn"
LogPathVariable="AspNetCoreRuntime31Log"
Compressed="yes">
</ExePackage>
</PackageGroup>
</Fragment>
</Wix>
We hope to get this functionality built in to v4 - https://github.com/wixtoolset/issues/issues/6257 and https://github.com/wixtoolset/issues/issues/6264.
For now, because the versioning for .NET Core is predictable and with predefined support windows and release cadence, you could brute force the search by searching for all 36-ish possible versions.
You can run code in a bundle by writing a custom BootstrapperApplication. If you're using the built-in BA wixstdba, it has an extensibility point called BAFunctions where you can write your own (native) .dll.

Include .exe file when deploying wpf application

I'm creating a WPF application that uses also the Kinect 2. Now it's time to publish my application and I would like to create a unique setup file that installs the application and the Kinect SDK. I have the Kinect .exe and I would like to include it in the standard setup I create with the publish option in Visual studio (btw I'm using Visual Studio 2017).
Reading some stuff I figure out that the right way could be to insert the Kinect SDK in the prerequisites of my application. Right?
Thus I'm trying to add the file, following these guides:
How to: Create a Package Manifest
How to: Create a Product Manifest
I have created a folder in C:\Program Files (x86)\Microsoft Visual Studio 14.0\SDK\Bootstrapper\Packages, I have added the product xml file:
<?xml version="1.0" encoding="utf-8" ?>
<Product xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
ProductCode="Custom.Bootstrapper.Package">
<PackageFiles>
<PackageFile Name="KinectRuntime-v2.0_1409-Setup.exe"/>
</PackageFiles>
<Commands>
<Command PackageFile="KinectRuntime-v2.0_1409-Setup.exe" Arguments="">
<InstallConditions>
<BypassIf Property="IsMsiInstalled"
Compare="ValueGreaterThan" Value="0"/>
<FailIf Property="AdminUser"
Compare="ValueNotEqualTo" Value="True"
String="NotAnAdmin"/>
</InstallConditions>
<ExitCodes>
<ExitCode Value="0" Result="Success"/>
<ExitCode Value="1641" Result="SuccessReboot"/>
<ExitCode Value="3010" Result="SuccessReboot"/>
<DefaultExitCode Result="Fail" String="GeneralFailure"/>
</ExitCodes>
</Command>
Then in a subfolder called "en" I added the package xml file:
<Package xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
Name="DisplayName"
Culture="Culture"
LicenseAgreement="SDKEula.rtf">
<PackageFiles>
<PackageFile Name="SDKEula.rtf"/>
</PackageFiles>
<!-- Defines a localizable string table for error messages. -->
<Strings>
<String Name="DisplayName">Update Consent Dialog</String>
<String Name="Culture">en</String>
<String Name="AU_Unaccepted">The automatic update agreement is not accepted.
</String>
<String Name="GeneralFailure">A failure occurred attempting to launch the setup.</String>
</Strings>
</Package>`
I also added the rtf file. So for me should be almost ok. But when I go back to VS I don't see this new package in the prerequisites list.
Can you help me to add the Kinect SDK installer?
Thank you very much,
Alex
Solved. I thought that the folder was right but instead looking in the key GenericBootstrapper I found that the packages' path was C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper. Adding the new package with the product and package xml in the folder I'm able to see the Kinect Installer in the prerequisites. Publishing the APP everything works

WiX installer does not work on vs 2012

I want to create a setup installer for my application. I have downloaded WiX 3.6 and installed it on vs 2012.
Create simple winform application
Add WiX setup project to my solution
Right click on reference and add my winform application to setup's reference
I build solution and go to debug directory in setup project and run SetupProject1.exe.msi it does not work and closes the installer dialog without any error.
Go back to setup project
Right click on setup project and select properties
On installer tab > output type, change it to executablefile.exe
Build it and go to debug and run SetupProject1.exe - still does not work
What is wrong? This is my setup project product.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="SetupProject1" Language="1033" Version="1.0.0.0" Manufacturer="Natiloos" UpgradeCode="cfc2f4dd-2da5-49e2-9099-96968d75aaa4">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="SetupProject1" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SetupProject1" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent"> -->
<!-- </Component> -->
</ComponentGroup>
</Fragment>
How can I get the installer to build correctly?
The problem is your installer is not installing anything. Adding your project as a reference to the installer does not mean the installer will include your projects output. In your setup project you have:
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent"> -->
<!-- </Component> -->
</ComponentGroup>
</Fragment>
You need to add the files...i.e. uncomment the <Component></Component> tags and add your files manually. It's good to have one <Component> tag per file.
Example:
<Component Id="MyProgram.exe" Guid="PUT-GUID-HERE">
<File Id="MyProgram.exe" KeyPath="yes" Source="Path_To_Output_Folder\MyProgram.exe" />
</Component>
WiX projects of the type that you are describing produce MSI files, with the .msi extension. These installers are not run directly, rather then are run using msiexec.exe. Windows explorer does this for you by default when you double click on them, however you can explicitly call msiexec using a command like the following
msiexec MyInstaller.msi
Note that MSI files are completely different from executables - changing the output name of your setup produce to have an .exe extension, or renaming the file to have an .exe extension won't work.
If you want to produce an .exe based installer then what you need is a bootstrapper. WiX has one called Burn, however if I were you I would worry about making an MSI that works first and then worry about creating an executable bootstrapper.

Categories