I have several related Windows registry entries that I want packaged inside an MSI, so that 1) there is an uninstall process, and 2) The fact that these registry entries have been applied to a given computer is documented by an Add/Remove Programs entry.
The problem is that I can get Wix# to do this just fine, but I can only get the MSI to build if all the registry entries are inside a "Dir" block, and that winds up actually creating a physical folder, which I don't want, on the target system.
As a temporary workaround, I wound up using Dir block, specifying a dummy "Temp" folder. The installer actually does create the folder, which I don't want; all I want is to have the registry entries applied.
WiX documentation describes its underlying construct, TargetDir, as essentially telling the installer to perform its actions on the target system. See http://wixtoolset.org/documentation/manual/v3/howtos/files_and_registry/write_a_registry_entry.html
In that native WiX XML example, it seems there will be no extraneous folder created on the target system; only the desired registry entries will be applied. What Wix# syntax construct can I use to have the registry entries applied, yet avoid having to create an actual folder on the target system?
All the Wix# samples I've seen thus far seem to have this side effect of creating an actual folder on the target system, whether you want one or not.
I know I could probably do this by taking .reg files of the registry entries, harvesting them to .wxs files with heat, and then building that to an msi with candle and light. I am really trying to keep this in the C#/Wix# world. C# is a well-understood skill set in my organization; WiX less so. (Acknowledging that Wix# is built on top of WiX features, and some degree of understanding of WiX and Windows Installer is essential; it's a comfort zone thing, being able to use C# instead of XML, not a fully logical thing.) Currently, we do a lot of these types of registry settings tasks manually, with no trail, and no simple, reliable uninstall.
/// <summary>
/// Configure the Event Log on a Windows (server) to have MyApplication Log settings and record an entry for it in Programs and Features.
/// Note that this program creates the Windows Installer MSI that accomplishes this.
/// This program creates a WiX XML file that is then compiled by the WiX Toolkit (Candle and Light) into the MSI file.
/// </summary>
internal class Script
{
public static void Main()
{
// Define a new Installer Project object
var project = new Project("SetupMyApplicationEventLog" ,
// Provide dummy "Temp" install directory to satisfy WiX# Syntactical requirement. There are no actual files being installed.
new Dir(@"Temp"),
/*
* Event Log Registration Entries, translated from .reg file
*/
// First, add the root level key of the tree of keys
//[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\MyApplication Log]
//"EventMessageFile"="C:\\Windows\\Microsoft.NET\\Framework64\\v2.0.50727\\EventLogMessages.dll"
new RegValue(
RegistryHive.LocalMachine,
@"SYSTEM\CurrentControlSet\Services\Eventlog\MyApplication Log",
"",
"") { AttributesDefinition = "Component:Win64=yes" },
//[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\MyApplication Log\STV.DSD.HQSYS.SERVICE2]
//"EventMessageFile"="C:\\Windows\\Microsoft.NET\\Framework64\\v2.0.50727\\EventLogMessages.dll"
new RegValue(
RegistryHive.LocalMachine,
@"SYSTEM\CurrentControlSet\Services\Eventlog\MyApplication Log\" + "STV.DSD.HQSYS.SERVICE2",
"EventMessageFile",
"C:\\Windows\\Microsoft.NET\\Framework64\\v2.0.50727\\EventLogMessages.dll") { AttributesDefinition = "Component:Win64=yes" },
//[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\MyApplication Log\STV.VFS.ONLINE]
//"EventMessageFile"="C:\\Windows\\Microsoft.NET\\Framework64\\v2.0.50727\\EventLogMessages.dll"
new RegValue(
RegistryHive.LocalMachine,
@"SYSTEM\CurrentControlSet\Services\Eventlog\MyApplication Log\" + "STV.VFS.ONLINE",
"EventMessageFile",
"C:\\Windows\\Microsoft.NET\\Framework64\\v2.0.50727\\EventLogMessages.dll") { AttributesDefinition = "Component:Win64=yes" } );
// Set the properties of the setup project
// Set UI to minimal; there are no choices to be made here.
project.UI = WUI.WixUI_ProgressOnly;
project.Manufacturer = "STV";
project.OutFileName = "SetupMyApplicationEventLog";
project.GUID = new Guid("037C625A-609C-4C2C-9689-62A075B88AD7");
// Assign version # to setup MSI property of type System.Version
project.Version = new Version(4, 0, 0, 0);
// Add the Win64 attribute to the package, to force a 64-bit MSI to be created
project.Package.AttributesDefinition = "Platform=x64";
// Trigger the MSI file build
Compiler.BuildMsi(project);
//// Also create the .wxs file so we can see what was sent to WiX to build the MSI
Compiler.BuildWxs(project);
Console.WriteLine("productVersion=" + project.Version);
Console.ReadLine();
}
}
}