3

Web Deploy サイト マニフェストに要素を追加するためのXinyang Qiu による非常に役立つブログ投稿をフォローしています。gacAssembly残念ながら、gacAssembly プロバイダーは、GAC への展開用にローカル アセンブリ(つまり、GAC にないもの)をパッケージ化できないようです。パッケージ時に、次のエラーが表示されます。

マニフェスト 'sitemanifest' 内の 1 つ以上のエントリが無効です。ライブラリ '<フル パス>\<アセンブリ>' を読み込めませんでした。指定されたアセンブリ名またはコードベースが無効でした。(HRESULT からの例外: 0x80131047)

私が提供しているパスをアセンブリの一部として解釈していると思いますが、これはもちろん私が意味するものではありません。

これを回避する方法はありますか?サーバーの GAC に展開するために、ローカル ディレクトリにあるアセンブリを Web Deploy パッケージに貼り付けることはできますか?

4

1 に答える 1

7

Web Deploy 2.0には、要件を正確に満たす新しいプロバイダーがあります。gacInstallプロバイダー(http://technet.microsoft.com/en-us/library/gg607836(WS.10).aspxを参照)を使用すると、アセンブリを組み込むことができます。宛先でGACされるソースパッケージ。

このような単純なマニフェストが与えられた場合:

<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

(もちろん、アセンブリに強い名前が付いている場合に限ります!)

これで、同じ原則をVSWebプロジェクトに適用できます。ただし、Web Deploy 2.xが、開発マシンとターゲットWebサーバーの両方にインストールされていることを確認する必要があります。<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>

私が追加したもう1つのことは、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アセンブリを参照している場合でも、ローカルアセンブリを参照している場合でも機能します。

お役に立てば幸いです:)

于 2011-05-03T22:33:16.433 に答える