zoukankan      html  css  js  c++  java
  • WiX安装选项注册程序集到GAC和VS的设计时环境

    Visual Studio的设计时引用组件的窗口中看到的程序集的位置和程序集的运行时位置是不一样的,特别是在全局程序集缓存(GAC)中的程序集,通过WiX制作Winodws安装程序的时候需要处理这个区别。

    VS的设计时的添加引用窗口看到的程序集的位置来自注册表SOFTWARE\Microsoft\.NETFramework\AssemblyFolders – 放在HKEY_LOCAL_MACHINE 下面就是针对所有的用户, 或者放在HKEY_CURRENT_USER 下面针对当前用户。

    WiX要把一个程序注册到GAC,只需要在File 上增加一个选项 Assembly=".net" 就可以了,但是注册到GAC的dll不会放到安装目录下方了,这就需要通过提供两个Component方式来处理,例如下面的配置:

    <?xml version="1.0" encoding="utf-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
      <Product Id="a960cf35-0779-43e8-923b-35638f2bfc42" Name="Minimal" Language="2052" Version="1.0.0.0" Manufacturer="Geffzhang" UpgradeCode="0bf7e020-5bbd-4a06-8e39-e715999edbf5">
        <Package InstallerVersion="200" Compressed="yes" Description="Minimal Windows Installer Sample" Comments="This installer database contains the logic and data required to install Minimal Windows Installer Sample." />
        <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
        <Property Id="EnableEV" Value="1">
        </Property>
        <Condition Message="你必须有管理员权限才能安装应用程序"><![CDATA[Privileged]]></Condition>
        <Directory Id="TARGETDIR" Name="SourceDir">
          <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLLOCATION" Name="Minimal">
              <Component Id="Component1" Guid="{1781A625-8ACB-45E7-A8BA-219D81760B2E}">
                <CreateFolder />
                <Environment Id="TestMinVar" Action="set" Part="all" Name="MinEnvVar" Permanent="no" System="yes" Value="8" />
                <File Id="File_Payload" Source="payload.txt" KeyPath="yes" />
              </Component>
              <Directory Id="GAC" Name="GAC">
                <Component Id="RTGACTest" Guid="22887611-B13E-41EE-897C-D78830E68AEB" DiskId="1">
                  <!-- Runtime, assembly in GAC -->
                  <File Id="F_RT_GACTEST"  LongName="GACTest.dll" Source="..\build\GACTest.dll" KeyPath="yes" Assembly=".net" />
                </Component>
              </Directory>
              <Component Id="DTGACTest" Guid="FB935B7D-D2BD-4B83-A26C-A9376EBA0915" DiskId="1">
                 <!--Design-time, private assembly--> 
                <File Id="F_DT_GACTest" LongName="GACTest.dll" Source="..\build\GACTest.dll" KeyPath="yes" />
                <Registry Id="R_DT_MyControl_AssemblyFolders" Root="HKLM" Key="SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\[ProductName]" Value="[$DTGACTest]" Type="string" />
              </Component>
            </Directory>
          </Directory>
        </Directory>
        <Feature Id="ProductFeature" Title="Minimal" Level="1">
          <ComponentRef Id="Component1" />
          <ComponentRef Id="DTGACTest"/>
          <ComponentRef Id="RTGACTest" />
        </Feature>
        <Property Id="WIXUI_INSTALLDIR" Value="INSTALLLOCATION" />
        <UIRef Id="WixUI_InstallDir" />
        <UI />
      </Product>
    </Wix>
    上面的例子的GACTest.dll注册了两个Component--RTGACTest和DTGACTest,RTGACTest下的File增加了属性Assembly=".net",DTGACTest则没有增加,同时在DTGATest增加了一个注册表项目。

    欢迎大家扫描下面二维码成为我的客户,为你服务和上云

  • 相关阅读:
    Java之美[从菜鸟到高手演变]之设计模式
    常见JAVA框架
    每周一荐:学习ACE一定要看的书
    YUV格式&像素
    关于makefile
    socket通信
    [理论篇]一.JavaScript中的死连接`javascript:void(0)`和空连接`javascript:;`
    [应用篇]第三篇 JSP 标准标签库(JSTL)总结
    [应用篇]第一篇 EL表达式入门
    KVM基本实现原理
  • 原文地址:https://www.cnblogs.com/shanyou/p/1359037.html
Copyright © 2011-2022 走看看