В 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 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>
OneДругое, что я добавил, это как gacInstall сборок выбираются, а именно через запись метаданных <GacInstall>True</GacInstall>
, добавляемую к соответствующим тегам <Reference/>
в файле project.csproj :
<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 или локальную.
Надеюсь, это поможет:)