Web Deploy 2.0 有一个完全符合您要求的新提供程序:gacInstall提供程序(参见http://technet.microsoft.com/en-us/library/gg607836(WS.10).aspx)允许将程序集嵌入到源包在目的地被 GAC'd。
给定一个像这样的简单清单:
<sitemanifest>
  <gacInstall path="C:\Temp\MyAssembly.dll"  />
</sitemanifest>
..您可以创建一个包含这样的程序集的包:
msdeploy -verb:sync -source:manifest="path to manifest.xml" -dest:package="path to package.zip"
..然后使用该软件包将其安装在远程计算机上的 GAC 中:
msdeploy -verb:sync -source:package="path the package.zip" -dest:auto,computerName=REMOTEMACHINENAME
(当然,前提是程序集有一个强名称!)
现在,同样的原理可以应用于 VS Web 项目。但是,您需要确保在开发机器和目标 Web 服务器上都安装了 Web Deploy 2.x。而不是指定<MsDeploySourceManifest Include="gacAssembly">它必须是<MsDeploySourceManifest Include="gacInstall">.
这是我尝试过的完整的 {projectName}.wpp.targets 文件(基于问题中提到的博客文章中的文件):
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <CreatePackageOnPublish>True</CreatePackageOnPublish>
    <IncludeGacAssemblyForMyProject>True</IncludeGacAssemblyForMyProject>
    <UseMsdeployExe>False</UseMsdeployExe>
  </PropertyGroup>
  <PropertyGroup>
    <!--Targets get execute before this Target-->
    <OnBeforeCollectGacAssemblyForPackage Condition="'$(OnBeforeCollectGacAssemblyForPackage)'==''">
    </OnBeforeCollectGacAssemblyForPackage>
    <!--Targets get execute after this Target-->
    <OnAfterCollectGacAssemblyForPackage Condition="'$(OnAfterCollectGacAssemblyForPackage)'==''">
    </OnAfterCollectGacAssemblyForPackage>
    <CollectGacAssemblyForPackageDependsOn Condition="'$(CollectGacAssemblyForPackageDependsOn)'==''">
      $(OnBeforeCollectGacAssemblyForPackage);
      Build;
    </CollectGacAssemblyForPackageDependsOn>
    <AfterWriteItemsToSourceManifest>
      $(AfterWriteItemsToSourceManifest);
      _PrintSourceManifests;
    </AfterWriteItemsToSourceManifest>
  </PropertyGroup>
  <PropertyGroup>
    <IncludeGacAssemblyForMyProject Condition="'$(IncludeGacAssemblyForMyProject)'==''">False</IncludeGacAssemblyForMyProject>
    <AfterAddContentPathToSourceManifest Condition="'$(AfterAddContentPathToSourceManifest)'==''">
      $(AfterAddContentPathToSourceManifest);
      CollectGacAssemblyForPackage;
    </AfterAddContentPathToSourceManifest>
  </PropertyGroup>
  <Target Name="CollectGacAssemblyForPackage"
          DependsOnTargets="$(CollectGacAssemblyForPackageDependsOn)"
          Condition="$(IncludeGacAssemblyForMyProject)">
    <ItemGroup>
      <MyGacAssembly Include="@(ReferencePath)" Condition="'%(ReferencePath.GacInstall)'=='true'" />
    </ItemGroup>
    <Message Text="MsDeployPath: $(MSDeployPath)" /> <!-- For debugging -->
    <Message Text="Adding [gacInstall]: %(MyGacAssembly.Identity)" />
    <ItemGroup>
      <MsDeploySourceManifest Include="gacInstall" Condition="$(IncludeGacAssemblyForMyProject)">
        <Path>%(MyGacAssembly.Identity)</Path>
      </MsDeploySourceManifest>
    </ItemGroup>
    <CallTarget Targets="$(OnAfterCollectGacAssemblyForPackage)" RunEachTargetSeparately="false" />
  </Target>
  <Target Name="_PrintSourceManifests">
    <!-- Just for debugging -->
    <Message Text="Exporting Manifests:" />
    <Message Text=" @(MsDeploySourceManifest) : %(MsDeploySourceManifest.Path)" />
  </Target>
</Project>
我添加的另一件事是如何选择gacInstall程序集,即通过添加到project.csproj文件<GacInstall>True</GacInstall>中的相应<Reference/>标签的元数据条目:
<Reference Include="System.Data">
  <GacInstall>True</GacInstall>
</Reference>
<Reference Include="MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f430b784831ac64e, processorArchitecture=MSIL">
  <HintPath>..\..\LIB\MyAssembly.dll</HintPath>
  <GacInstall>True</GacInstall>
</Reference>
无论您引用的是 GAC 程序集还是本地程序集,这都有效。
希望有帮助:)