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アセンブリを参照している場合でも、ローカルアセンブリを参照している場合でも機能します。
お役に立てば幸いです:)