我有几个相关的Windowsregistry项,我想打包在一个MSI内,所以1)有一个卸载过程,和2)这些registry项已应用到给定的计算机的事实由一个添加/删除程序条目。
问题是我可以让Wix#做到这一点,但我只能得到微星build立,如果所有的registry项都在一个“Dir”块内,这实际上创build一个物理文件夹,我不不要在目标系统上。
作为一个临时的解决方法,我使用了Dir块,指定了一个虚拟的“Temp”文件夹。 安装程序确实创build了我不想要的文件夹; 我想要的只是应用registry项。
WiX文档描述了其基础结构TargetDir,主要是告诉安装程序在目标系统上执行其操作。 见http://wixtoolset.org/documentation/manual/v3/howtos/files_and_registry/write_a_registry_entry.html
Subversion在哪里保存?
64位.Net应用程序中的内存限制?
如何以编程方式closures或打开“Windowsfunction”
以编程方式获取Windows体验索引值
使连续运行的ac#应用程序
在那个原生的WiX XML例子中,似乎在目标系统上不会创build多余的文件夹。 只有所需的registry项将被应用。 我可以使用什么Wix#语法构造来应用registry项,但又不必在目标系统上创build实际的文件夹?
到目前为止,我所见过的所有Wix#示例似乎都有在目标系统上创build实际文件夹的副作用,无论您是否想要。
我知道我可以这样做,通过采取registry项的.reg文件,收集到.wxs文件与热,然后build立到蜡烛和光msi。 我真的想把这个保留在C#/ Wix#世界中。 C#是我的组织中熟知的技能; WiX不那么如此。 (承认Wix#是build立在WiXfunction的基础之上的,对WiX和Windows Installer的理解是必不可less的;这是一个舒适区域,能够使用C#而不是XML,而不是完全合乎逻辑的事情。)目前,我们手动执行了许多这些types的registry设置任务,没有跟踪,也没有简单可靠的卸载。
/// <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_MACHInesYstemCurrentControlSetServicesEventlogMyApplication Log] //"EventMessageFile"="C:\Windows\Microsoft.NET\Framework64\v2.0.50727\EventLogMessages.dll" new RegValue( RegistryHive.LocalMachine,@"SYstemCurrentControlSetServicesEventlogMyApplication Log","","") { AttributesDeFinition = "Component:Win64=yes" },//[HKEY_LOCAL_MACHInesYstemCurrentControlSetServicesEventlogMyApplication LogSTV.DSD.Hqsys.SERVICE2] //"EventMessageFile"="C:\Windows\Microsoft.NET\Framework64\v2.0.50727\EventLogMessages.dll" new RegValue( RegistryHive.LocalMachine,@"SYstemCurrentControlSetServicesEventlogMyApplication Log" + "STV.DSD.Hqsys.SERVICE2","EventMessageFile","C:\Windows\Microsoft.NET\Framework64\v2.0.50727\EventLogMessages.dll") { AttributesDeFinition = "Component:Win64=yes" },//[HKEY_LOCAL_MACHInesYstemCurrentControlSetServicesEventlogMyApplication LogSTV.VFS.ONLINE] //"EventMessageFile"="C:\Windows\Microsoft.NET\Framework64\v2.0.50727\EventLogMessages.dll" new RegValue( RegistryHive.LocalMachine,@"SYstemCurrentControlSetServicesEventlogMyApplication Log" + "STV.VFS.ONLINE","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); // 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(); } }
}
在Windows Mobile上编程ActiveSync
分布式locking机制.NET
在扩展打开/保存文件对话框中的视觉风格exception
添加应用程序清单以确保在Windows XP,Vista和7上提升权限的可靠程度如何?
如何检测Windows 8操作系统使用C#4.0?
您可以通过在您不希望保留的目录中将<RemoveFolder>标记添加到组件中来实现您想要的功能。 看参考 。
产生的MSI将通过警告LGHT1079 light创建,您没有任何文件,但可以忽略,如果这是意图。
简单示例XML,显示具有在安装/卸载时删除文件夹的组件的目录,并创建注册表项,在卸载时强制删除。
<Directory Id="TARGETDIR" Name="SourceDir"> <Component Id="ApplicationRegistry" Guid="YOUR-GUID-HERE"> <RemoveFolder Id="RemoveTarget" Directory="TARGETDIR" On="both"/> <RegistryKey Root="HKCU" Key="SoftwareMicrosoft[ProductName]" ForceDeleteOnUninstall="yes"> <RegistryValue Type="integer" Name="SomeIntegerValue" Value="1" KeyPath="yes"/> <RegistryValue Type="string" Value="Default Value"/> </RegistryKey> </Component> </Directory>
你只需要使用这个名字作为你的目录,或者用目录名称替换Directory="TARGETDIR" 。
你必须弄清楚如何将这个标签放到你生成的XML中,但这就是你需要的效果。
使用Ryan J提供的Wix XML代码,再加上Wix#示例代码中的“InjectXML”示例,我成功地生成了wxs文件并获得了可用的MSI,同时仍然保留在Visual Studio中的Wix#编码环境中。
以下是元素之前生成的相关.wxs XML:
<Directory Id="TARGETDIR" Name="SourceDir" > <Directory Id="INSTALLDIR" Name="%Temp%"> <Component Id="INSTALLDIR.EmptyDirectory" Guid="037c625a-609c-4c2c-9689-62a075b88ae9"> <CreateFolder /> </Component>
所以需要做的是:1)删除产品/目录/目录/组件下的“”元素。 Ryan J的例子清楚地表明,它是在与Wix#生成的XML中的“TARGETDIR”中的第一个“目录”相关联的“组件”之下。
2)在元素Product / Directory / Directory / Component下插入元素语法“”。 虽然我相信也可以在这个元素中引用Id“INSTALLDIR.EmptyDirectory”,但是我使用了Id“TARGETDIR”,并且按照我想要的方式工作。
这里是由Ryan J.提供的注入XML的Wix#代码
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(@"TempDeleteMe"),... // Hook up a delegate to the "WixSourceGenerated" event,fires when .wxs file is fully created Compiler.WixSourceGenerated += InjectXMLElement; // Trigger the MSI file build Compiler.BuildMsi(project); ... /// Insert XML elements and attributes into the generated .wxs file static void InjectXMLElement(System.Xml.Linq.XDocument document) { // Remove the <CreateFolder /> tag from Directory element -- we don't want to create it var createFolderElement = document.Root.Select("Product/Directory/Directory/Component/CreateFolder"); createFolderElement.Remove(); // To cause the folder to not be created on the target system,add this element: // <RemoveFolder Id="RemoveTarget" Directory="TARGETDIR" On="both"/> var componentElement = document.Root.Select("Product/Directory/Directory/Component"); componentElement.Add(new XElement("RemoveFolder",new XAttribute("Id","RemoveTarget"),new XAttribute("Directory","TARGETDIR"),new XAttribute("On","both"))); }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。