How to package vcruntime140.dll for a wix custom action DLL written by native c++? - wix

My wix wxs has a CustomAction written by c++: HSRInstall.dll. Inside this dll, windows swdevice.lib, new.lib are linked. So it requires running with vcruntime140.dll. When user execute this msi package on a clean install windows server 2019 datacenter, without a vcruntime140.dll in C:\Windows\System32, it will fail to be installed.
<Binary Id="HSRInstalldll" SourceFile="HSRInstall.dll" />
<CustomAction Id="deletehsrservicecache" BinaryKey="HSRInstalldll" DllEntry="HSRCustomAction" Execute="deferred" Impersonate="no" Return="ignore" />
When I add vcruntime140.dll as binary element in wxs, its file name is changed when installing. How to add the vcruntime library that the dynamic library depends on to the wix package? Thanks!

The best option is to statically link the C runtime (CRT) into your custom action dll. That way you do not have a dependency outside of your installation package.
We statically link the CRT in all the WiX custom actions.

Related

How do I install drivers using Burn and DPInst after MSI installation?

I have a setup MSI for our application, and I also have signed FTDI drivers that need to be installed as well. I'd like for them to be installed with Burn rather than the WiX MSI to keep CustomActions out of the MSI (however, I've tried the CA route as well).
I've tried putting the instruction in an ExePackage, but the SourceFile attribute asks for the file location during build, not runtime (e.g. <ExePackage Id="InstallDrivers" DisplayName="Installing Drivers" SourceFile="[InstallFolder]Drivers\DPInst.exe" InstallCommand="/SA /SW" PerMachine="yes" After="MyMSISetup" Description="Installing the FTDI drivers needed for device communication." /> doesn't build).
Is there a way to tell Burn to execute DPInst using the file location of where the drivers will be after installation of the MSI? Currently the MSI copies the driver files and DPInst into a Drivers folder in the install directory. After looking online and here on Stack Overflow, I doesn't seem like anyone else is doing this.
I've also tried using the CustomAction route in the MSI, but the CustomAction fails to execute. I'd like the drivers to be installed with Burn, but if they work with the MSI I'd settle for that. Currently the MSI copies the files to the Drivers folder, and the CustomAction looks like this:
<InstallExecuteSequence>
<Custom Action="Install_Signed_Driver" After="InstallFiles">NOT INSTALLED</Custom>
</InstallExecuteSequence>
<Fragment>
<CustomAction Id=Install_Signed_Driver" Execute="deferred" Directory="Drivers" ExeCommand="[Drivers]DPInst.exe" /SW /SA" Return="ignore" />
</Fragment>
As near as I can tell, the custom action never runs. I've even taken off the /SW and /SA switches to see if anything loads, and nothing.
Per StackOverflow's suggestion, I'm posting what I found here. I was never able to get Burn to run DPInst for the driver installation, but was able to get the CustomAction to work using Can't seem to get Wix to install driver.

Publish .Net library in COM using Wix Installer

I'm trying to register a library on COM using WiX installer, but it seems to be ignoring me.
What I've tried so far is:
Used heat.exe to harvest all the info corresponding to the .dll.
Created a fragment containing all the information that I harvested from heat.exe.
I copied all the harvested information into a single component, to make things easier.
I call the component using a ComponentRef that points to the component containing the related info for the dll to register.
I used a custom action to register it to the COM:
<CustomAction Id="RegisterComLibrary" Directory="ComPublishDllFolder" ExeCommand="regsvr32.exe /s [ComPublishDllFolder]MyLibrary.dll />
Insert the CustomAction in the InstallExecuteSequence:
<InstallExecuteSequence>
<Custom Action="RegisterComLibrary" After="InstallFinalize">NOT Installed</Custom>
</InstallExecuteSequence>
But then, when I try to find the .dll in the COM using oleview or trying to use it with Visual Studio, I can't see it.
What I'm doing wrong?
NOTE: I'm getting the following message while trying to register it manually:
The module "MyComObject.dll" was loaded but the call to DllRegisterServer failed.
Ensure that "MyComObject.dll" is a valid DLL or OCX and try again.
Sorry, it was completely my fault. A misunderstanding of how .Net dlls published in COM work.
When I published my .Net compiled dll in COM and tried to use it in a .Net project, it launched a message saying that I can't use a COM library compiled in .Net, as it is a .Net library.
At first I thought it was a mistake, but actually, if I try to use the library in a C++ project (for example), it works fine.
The problem is that Visual Studio doesn't allow to consum COM libraries published in the same language that you built your project, apparently...

Wix Burn Bundle - Must be Administrator

I've created a WIX Burn Bundle. In the Bundle I install .Net 4 (if its not installed) then 2 more .msi files. 1 is a third part msi the other a msi I created for my software using WIX. I need to be an Administrator on the machine to run these the .msi files.
I want the Burn bundle to not do anything if the user is not an administartor i.e. install nothing. In my product software I can easily do do using below - however I cant do this in the bundle. I've read lots of similar posts but just didnt find a working example for what I want to do.
<CustomAction Id="IsPrivileged" Error="You must be an Administrator to install [ProductName]." />
<InstallExecuteSequence>
<Custom Action='IsPrivileged' Before='LaunchConditions'>
Not Privileged
</Custom>
</InstallExecuteSequence>
You can use the bundle equivalent of launch conditions using Burn's built-in variables and WixBalExtension's Condition element:
<bal:Condition Message="You can't elevate.">
<![CDATA[Privileged <> 0]]>
</bal:Condition>
<bal:Condition Message="You're not elevated.">
WixBundleElevated = 1
</bal:Condition>

Wrap an EXE installer inside a WIX msi

I found this article that shows how to call an EXE installer at the end of an installation done with a WIX installer.
Unfortunately, it does not quite work for me: the EXE does not start after the installation completes. Does anyone has a working example? Unless there is something easy to change from Mr. Ryan's example?
Any input would be greatly appreciated!
You can use the WIX v3.6 Bundle concept to handle this. You can read more about it here
http://wix.sourceforge.net/manual-wix3/authoring_bundle_intro.htm
Basically you are packaging your WIX MSI and the EXE into a single WIX bundle package which can be then installed to the target machines.
I also wanted to keep the UI from the MSI so I added this code to start an exe installer for hardware keys. I know it goes against MSI Best Practices but this is the only one I intend on breaking. Hope this helps.
<Property Id="WixShellExecTarget" Value="[#myapplication.exe]" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
I then ran the custom action from a button click. Or you could schedule it to run after InstallFinalize.
Mr. Ryan here :)
in case this is of use:
this is the WiX project I made, to install Report Viewer 2010 using GPO (Group Policy)
http://www.natureireland.com/Downloads/StackOverflow/oRV2010Installer.rar
note: I used WiX version: Windows Installer XML v3.5
regards
sean

Wix and custom .net dll

I'm searching for some complete sample of wix project with reference to .NET dll (complete wix VS project, .net dll VS project, and compiled .net dll).
I'm trying to run SampleAskKeyNet and constantly I got error "There is a problem with this Windows Installer package. A DLL required for this installation to complete could not be run. Contact your support personnel or package vendor and I'm trying to find what I made wrong.
I created wix project in VS, .net dll project in VS, compiled dll project, copy over CheckPidPackage.dll to wix VS project directory and compile wix project. Then I run it and I get this error.
Link mentioned in accepted answer(by user431821) was indeed helpful but posting the exact thing which was helpful to me.
Custom actions project creates 2 dlls. If project is CustomActionProject, it will create CustomActionProject.dll and CustomActionProject.CA.dll
I was referencing to CustomActionProject.dll as below which is regular dll.
<Binary Id="CustomActionProject"
src="..\CustomActionProject\bin\$(var.Configuration)\CustomActionProject.dll" />
<CustomAction Id="MyAction"
Return="check"
BinaryKey="CustomActionProject"
DllEntry="Validate"/>
WIX creates CustomActionProject.CA.dll which is actually NOT the .NET managed assembly but unmanaged assembly. SO we have to refer to it instead of regular one.
<Binary Id="CustomActionProject"
src="..\CustomActionProject\bin\$(var.Configuration)\CustomActionProject.CA.dll" />
<CustomAction Id="MyAction"
Return="check"
BinaryKey="CustomActionProject"
DllEntry="Validate"/>
This solved my issue.
Maybe this could be useful: http://www.codeproject.com/KB/install/wixcustomaction.aspx
For me, it was my CustomAction DllEntry did not match my method name. i.e.
<CustomAction Id="CheckingPID" BinaryKey="CheckPID.CA" DllEntry="BadValue" />
public static ActionResult CheckPID(Session session)
I forgot to use MakeSfxCA.exe on dll in order to wrap it.
More details here Custom Action in C# used via WiX fails with error 1154 and here http://blog.deploymentengineering.com/2008/05/deployment-tools-foundation-dtf-custom.html