lad*_*dge 3 .net gac msdeploy webdeploy
我一直在关注Xinyang Qiu的一篇非常有用的博客文章,gacAssembly内容是为我的Web Deploy网站清单添加元素.遗憾的是,gacAssembly提供程序似乎无法打包本地程序集(即不在GAC中的程序集)以部署到GAC.在打包时,我收到以下错误:
清单'sitemanifest'中的一个或多个条目无效.无法加载库"<完整路径>\<程序集>".给定的程序集名称或代码库无效.(HRESULT异常:0x80131047)
我认为它正在解释我作为装配名称的一部分提供的路径,这当然不是我的意思.
这有什么办法吗?是否可以将位于我本地目录中的程序集粘贴到Web Deploy程序包中以部署到服务器的GAC?
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>
Run Code Online (Sandbox Code Playgroud)
..你可以创建一个包含这样的程序集的包:
msdeploy -verb:sync -source:manifest="path to manifest.xml" -dest:package="path to package.zip"
Run Code Online (Sandbox Code Playgroud)
..然后使用该软件包将其安装在远程计算机上的GAC中:
msdeploy -verb:sync -source:package="path the package.zip" -dest:auto,computerName=REMOTEMACHINENAME
Run Code Online (Sandbox Code Playgroud)
(当然,如果组件有一个强大的名字!)
现在,相同的原理可以应用于VS Web项目.但是,您需要确保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>
Run Code Online (Sandbox Code Playgroud)
我添加的另一件事是如何选择gacInstall程序集,即通过<GacInstall>True</GacInstall>添加到project.csproj文件中的相应<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>
Run Code Online (Sandbox Code Playgroud)
无论您是引用GAC程序集还是本地程序集,它都可以工作.
希望有帮助:)
| 归档时间: |
|
| 查看次数: |
1690 次 |
| 最近记录: |