安装到GAC并在注册表中注册

时间:2012-11-15 15:48:26

标签: wix gac

好的,我显然错过了一些东西。我正在尝试关注this以便安装到GAC并进行开发。但是,唯一发生的事情是DLL被放入ProductDirectory。它没有出现在GAC中,也没有添加注册表项。我怎样才能让它发挥作用?

以下Product.wxs的相关部分。

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" Name="Me.Common" Language="1033" Version="1.0.0.0" Manufacturer="Me" UpgradeCode="ea52947a-0980-435d-a8f5-280d3526cb90">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
    <!-- The feature to install. -->
        <Feature Id="ProductFeature" Title="Me.Common" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
        </Feature>
    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
        <Directory Id="ProductDirectory" Name="Me.Common">
          <Directory Id="GAC" Name="GAC" />
        </Directory>
            </Directory>
        </Directory>
    </Fragment>

    <Fragment>
        <ComponentGroup Id="ProductComponents">
      <Component Id="RunTime_Me.Common" Directory="GAC" Guid="E2B19C22-DC01-432D-85B0-0E4948F95A43">
        <!-- Add to GAC. -->
        <File Id="RunTime_Me.Common"
              Source="$(var.Me.Common.TargetDir)$(var.Me.Common.TargetFileName)"
              Assembly=".net"
              KeyPath="yes" />
      </Component>
      <Component Id="DesignTime_Me.Common" Directory="ProductDirectory" Guid="C1BD8CD1-E834-49D5-B499-D9E313E70669">
        <!-- Add locally. -->
        <File Id="DesignTime_Me.Common"
              Source="$(var.Me.Common.TargetDir)$(var.Me.Common.TargetFileName)"
              KeyPath="yes" />
        <!-- Add to registry so that Visual Studio can find it via Add Reference. -->
        <Registry Id="Registry_DesignTime_Me.Common_AssemblyFolders"
                  Root="HKLM"
                  Key="SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\[ProductName]"
                  Value="[$DesignTime_Me.Common]"
                  Type="string" />
      </Component>
        </ComponentGroup>
    </Fragment>
</Wix>

原来它已经在GAC中安装了。我在错误的地方寻找; .NET现在有4.0个项目的第二个GAC(C:\ Windows \ Microsoft.NET \ assembly)。这留下了注册表项。我收到一条警告,Registry已弃用,所以我用下面的代码替换了该组件,但仍无效:

  <Component Id="DesignTime_Me.Common" Directory="ProductDirectory" Guid="C1BD8CD1-E834-49D5-B499-D9E313E70669">
    <!-- Add locally. -->
    <File Id="DesignTime_Me.Common"
          Source="$(var.Me.Common.TargetDir)$(var.Me.Common.TargetFileName)"
          KeyPath="yes" />
    <!-- Add to registry so that Visual Studio can find it via Add Reference.
         These require .NET v4.0 minimum. -->
    <RegistryKey Root="HKLM"
                 Key="SOFTWARE\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\[ProductName]">
      <RegistryValue Type="string" Value="[$DesignTime_Me.Common]" />
    </RegistryKey>
  </Component>
</ComponentGroup>

2 个答案:

答案 0 :(得分:4)

一切正常;我只是在错误的地方寻找。

4.0 GAC位于C:\Windows\Microsoft.NET\assembly。 注册表项放在SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\[ProductName]中,因为安装程序是32位。

答案 1 :(得分:1)

由于你的文件中至少有一个是正常的,我猜你没有升级。尝试将InstallPrivileges =“elevated”添加到您的包元素中。

<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" InstallPrivileges="elevated" />