Wix installer integration with text file - wix

I have an installation that copy files to the relevant location,install some of them in the GAC and install services.
I'm looking for a way to improve my installer and ease my application configuration by adding forms to the installer with some edit box which eventually will replace strings in my application configuration files, that way it will be more comfortable and user friendly to configure the application setting.
Is that possible?
if so, where should I look on how to do this?

From what you are asking, it looks like you would like to introduce some User Interface as part of your installation process. Wix has several inbuilt UI dialog sets that can help you do just this.
Take a look at the following:
http://wixtoolset.org/documentation/manual/v3/wixui/wixui_dialog_library.html
http://wixtoolset.org/documentation/manual/v3/wixui/wixui_customizations.html
https://www.firegiant.com/wix/tutorial/user-interface/
https://www.firegiant.com/wix/tutorial/user-interface-revisited/
Hope this helps.
If you would like to introduce a custom dialog in the user interface sequence, take a look at:
http://wixtoolset.org/documentation/manual/v3/wixui/wixui_customizations.html
https://www.firegiant.com/wix/tutorial/user-interface-revisited/a-single-dialog/
Try things out. These examples should be sufficient to help you get started.

Related

Encrypting connections strings in Visual Studio 2017

Hi I'm hoping this isn't too vague to get some help with!
We've searched for several days now and cannot get an answer that works. We use Advanced Installer for different projects and need a sensible way to encrypt the connection strings for sites that do NOT use windows authentication into the sql server.
We've tried encryption after installation, running custom DLL's in Advanced Installer and all sorts. Nothing works because of Microsoft's frustrating permissions fortress around Program Files folder.
Does anyone know of a decent way to do this that does not involve Windows Authentication on the database?
Any help would be very warmly appreciated. As you can imagine, this request is made as a last ditch attempt to find a good solution.
I'm rather shocked that there isn't one that is fairly standard - but if you don't use Windows Authentication on SQL server, I don't see one as far as I can tell.
Thank you in advance for any help offered!
Warmest regards
Richard
Edit: From what I understand the encrypt/decrypt can only be done on the same machine - preventing me from shipping an encrypted app.config. The key is based on a machine.config that differs by machine.
I finally found the key to solving this with Advanced Installer - it can't run DLLs that are built in managed code, so you need to use another toolset called Wix to create a DLL that Advanced Installer can use. The instructions for that can be found here: https://www.advancedinstaller.com/user-guide/qa-c-sharp-ca.html
For the encryption we're after, this is the function I created as a custom action in the Wix project (for clarity, minus the try-catch, file check and logging that our actual code has):
<CustomAction()>
Public Shared Function Encrypt(session As Session) As ActionResult
Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(session.CustomActionData("ExecutablePath"))
Dim section As ConnectionStringsSection = TryCast(config.GetSection("connectionStrings"), ConnectionStringsSection)
If section.SectionInformation.IsProtected Then Return ActionResult.SkipRemainingActions
section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider")
If Not section.SectionInformation.IsProtected Then Return ActionResult.Failure
config.Save()
Return ActionResult.Success
End Function
When you build the project, it generates two DLL files: a normal .dll and a .CA.dll. In the Advanced Installer project, add the .CA.dll to the included files (preferably as a temporary file since it's only needed during installation). Then go to custom actions, add a new "Call Function From Attached Native DLL" action, point it at the same .CA.dll file as you selected to add to the project, and then set up the rest of the action like this:
(attached image)
...where [#ConfigEncryptionTestProgram.exe] should be replaced with your executable!
The important bits here are the position of the action in the sequence (just before Finish Execution), the execution time (commit), and the execution option that makes it run with privileges so that it can get around Microsoft's restriction on modifying files in the Program Files folder.
I have done this and have written not a single line of real code.
I have just added to the installer a custom action for encryption:
Launch File (With Sequence)
File to launch: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe
Command line: -pe connectionStrings -app /myappname
Hide program's window
You would set "Run as administrator" (not applicable to us, because our installer completely runs as administrator)
Execution Time: Immediately
Wait for custom action to finish before proceeding
DO NOT Fail installation if custom action returns an error
and another one for decryption, same settings, but with command line -pd instead of -pe.
And then I have moved the decryption before the "Dialogs->Searches" stage, and the encryption behind the "Execution->InstallFinalize" stage:

Component in merge module needs to be run once 'As Administrator' when UAC is on

I am writing my first WIX installer. The installed application uses various Microsoft standard OCX controls which are installed as merge modules, for example MSCOMCTL.msm, MSFLXGRD.MSM etc.
For some reason, if the target machine has UAC switched on, running the application after installation fails with a message to the effect that "MSCOMCTL is missing or has not been correctly registered...". However, if the application is run once 'As Administrator' it puts up a UAC "can this app make changes" message (so it's obviously changing something) and then runs fine, and what is more runs forever after without admin privs. (Alternatively, registering the relevant controls with RegSrv works as well).
I have monitored the application with ProcMon and it is obviously doing a late registration. It is as if the installer has advertised the contents of the merge module without installing them. I've also looked at the merge module, and my MSI, with Orca, but I can't work out any way of stopping this behavior.
I did wonder if it was anything to do with the versions of the MSMs, but it seems almost impossible to find out what the latest version of these Microsoft MSMs is, or to find anywhere to download them.
Obviously we do not want to make our customers go through this convoluted process when they install our product. Any suggestions would be greatly appreciated.
Thanks Kiran. We also read that bit in the MSDN documentation. The problem is that we can't alter the Advertise attributes on items that are already built into Microsoft's Merge Modules (well, we could using Orca but it would be messy).
However, I think we may have found the source of the problem. The previous release of our product used a kit built using InstallShield. When we compared the .MSI created by InstallShield to the one created with Wix we noticed that the InstallExecuteSequence table of the IS one contains RegisterProgIdInfo, RegisterClassInfo and RegisterTypeLibraries, which do not appear in the Wix-generated MSI. We think some or all of these may be needed to force the MSMs to install. I need to find out how to put these into Wix, and then to try it to see if it works. I will try to remember to post the result here for posterity.
[Following day] Confirmed. For anyone else who has this problem, you just need to put a <RegisterClassInfo/> tag and a <RegisterProgIdInfo/> tag (and maybe a <RegisterClassLibraries/> tag, but I didn't need one of those) into your <InstallExecuteSequence>.

WIX get substring from variable

As part of my WIX setup project, I am updating some values in the app config for the service I am installing. One of the attributes is a number, this is the number of the location the service is being installed at.
The location is part of the machine name, for example the machine name might be "location16server". I am trying figure out if I can get a substring or otherwise parse the number out of the machine name so that I may use it to update the .config file. I don't see any ways that are part of WIX, but maybe with a custom action?
Thanks
A custom action would be required. I'd provide caution on this though as you are tightly coupling along a machine name. This might work well in a controlled environment but could cause major headaches down the road. I'd look for some other artifact on the machine to determine location numbers and other configuration data. Perhaps even move it out of the installer and into the application if possible.
Another option is to insert a dialog box that allows the user to enter some optional parameters for the program being installed.
Here are some examples:
http://www.merlinia.com/mdt/WiXTutorial3.msl
http://wix.tramontana.co.hu/tutorial/user-interface/new-link-in-the-chain

BURN (WIX bootstrapper) - files in use dialog not being shown

I have created a WIX msi for one of our products which works really well. The product is a Word addin and at upgrade/uninstall the msi automatically checks if Word is open (ie. my assemblies are currently locked in execution) and if it is, then it comes up with the Files In Use dialog.
The only improvement I would like to make is at installation time. I would like to check whether word is open and force close before install. It would be great to do so, using the same Files In Use UI. Is there an easy way to do this?
I have also created a custom bootstrapper (unmanaged), using the sample code from the toolset. Overall this is really good too, however I have real problems when upgrading/uninstalling. Ideally, I don’t want to DisplayInternalUI but I would like the Files In Use to pop up when necessary. Is this possible?
The feature request 4382 was implemented and is available in v3.10.0.1726. Set ShowFilesInUse to yes in the WixStandardBootstrapperApplication element.

WIX Installer for Test/Live Environment

I have to create a set up file for a client app for LIVE/QA/UAT environments and the only difference between them is the app.config file. Can you please suggest an easy way to accomplish it?
A good approach is modifying a template app.config based on user input:
configure your app.config file to use installer properties: http://wix.sourceforge.net/manual-wix2/wix_xsd_xmlfile.htm
create some custom dialogs which retrieve the element information from the user and save them in your custom properties
If you need to update just certain value in app.config based on user input, then the solution outlined by #Cosmin would work best. There are a couple of other options depending on your requirements:
in case you can define the app.config differences at buildtime, and if it's fine to have 3 different MSI packages (one per environment), it's better to author 3 components holding the app.config for each environment wrapped in the preprocessor logic. As a result, you'll end up with an MSI package for a specific environment depending on how you build
in case the choice depends on a certain user input, you can still author 3 different components with mutual exclusive conditions, and this conditions will depend on the user input
I've solved this before by using something along the lines of this in my main wxs file:
<?include $(sys.CURRENTDIR)Properties$(var.Configuration).wxi?>
(It points to e.g. C:\MyProjectDir\PropertiesDebug.wxi, C:\MyProjectDir\PropertiesUAT.wxi, etc. depending on the active solution configuration).
However, I now prefer using the new Microsoft method of having the web.config and app.config transforms for each platform, because it can help to shift the burden of maintaining these settings onto the developers who create them as they go, rather than just leaving it all to the guy that writes the installer app at the end.
The app.config transforms are not built into VS2010, but there is an add-in available:
http://visualstudiogallery.msdn.microsoft.com/69023d00-a4f9-4a34-a6cd-7e854ba318b5
The web.config transforms are built in already:
http://blogs.msdn.com/b/webdevtools/archive/2009/05/04/web-deployment-web-config-transformation.aspx