网络能部署软件包地方议会目标服务器的GAC? [英] Can Web Deploy package local assemblies for the target server's GAC?

查看:150
本文介绍了网络能部署软件包地方议会目标服务器的GAC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在关注一个非常有用的由信阳邱博客帖子添加 gacAssembly 元素,以我的Web部署的网站清单。不幸的是,的gacAssembly提供商不会出现要能打包的当地组装的(即一个不是在GAC)部署到GAC。在包装的时候,我收到以下错误:

I've been following a very helpful blog post by Xinyang Qiu for adding gacAssembly elements to my Web Deploy site manifest. Unfortunately, the gacAssembly provider doesn't appear to be able to package a local assembly (that is, one not in the GAC) for deployment to the GAC. At package time, I receive the following error:

在清单中的一个或多个条目   'sitemanifest'是无效的。该   图书馆<全路径> \<装配>可以   不会被加载。给定的程序集名称   或codeBase的是无效的。 (例外   来自HRESULT:0x80131047)

One or more entries in the manifest 'sitemanifest' are not valid. The library '<full path>\<assembly>' could not be loaded. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

我觉得这是除preting我提供的组件的一部分路径的名称的,这当然不是我的意思。

I think it's interpreting the path I'm supplying as part of the assembly name, which of course isn't what I mean.

有一些解决这个办法吗?是否有可能装配坐在我的本地目录到Web部署包部署坚持一个服务器的GAC?

Is there some way around this? Is it possible to stick an assembly sitting in my local directory into a Web Deploy package for deployment to a server's GAC?

推荐答案

网络部署2.0有一个新的供应商,以满足您的确切要求:在 gacInstall 提供商(请参阅<一href="http://technet.microsoft.com/en-us/library/gg607836(WS.10).aspx">http://technet.microsoft.com/en-us/library/gg607836(WS.10).aspx)允许内嵌在源代码包的组件将在目标GAC'd。

Web Deploy 2.0 has a new provider that meets exactly your requirements: the gacInstall provider (see http://technet.microsoft.com/en-us/library/gg607836(WS.10).aspx) allows for an assembly embedded in a source package to be GAC'd at the destination.

给出一个简单的清单是这样的:

Given a simple manifest like this:

<sitemanifest>
  <gacInstall path="C:\Temp\MyAssembly.dll"  />
</sitemanifest>

..你可以创建一个包含组件这样的包:

..you can create a package that contains the assembly like this:

msdeploy -verb:sync -source:manifest="path to manifest.xml" -dest:package="path to package.zip"

..然后在GAC在远程计算机上使用包进行安装:

..and then install it in the GAC on a remote machine using that package:

msdeploy -verb:sync -source:package="path the package.zip" -dest:auto,computerName=REMOTEMACHINENAME

(向大会当然有一个强大的名字,!)

(Provided the assembly has a strong name, of course!)

现在,相同的原理可以应用于一个VS Web项目。你需要确保,虽然,网络部署2.x是安装在两个,在开发计算机和目标Web服务器上。而不是指定和&LT; MsDeploySourceManifest包括=gacAssembly&GT; 它必须是&LT; MsDeploySourceManifest包括=gacInstall&GT;

Now, the same principle can be applied to a VS Web project. You need to make sure, though, that Web Deploy 2.x is installed on both, the development machine as well as on the target web server. And instead of specifying <MsDeploySourceManifest Include="gacAssembly"> it has to be <MsDeploySourceManifest Include="gacInstall">.

下面是一个完整的{} PROJECTNAME文件.wpp.targets我已经试过了这一点与(基于来自博客文章的一个在问题中提到):

Here's a complete {projectName}.wpp.targets file I've tried this out with (based on the one from the blog post mentioned in the question):

<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 的组件选择,即通过一个元数据项&LT; GacInstall&GT;真&LT; / GacInstall&GT; 添加到相应的&lt;参考/&GT; 标签内的 project.csproj 的文件:

One other thing I've added is how the gacInstall assemblies are selected, namely via a metadata entry <GacInstall>True</GacInstall> added to the respective <Reference/> tags inside the project.csproj file:

<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组件或局部的。

And that works no matter if you're referencing a GAC assembly or a local one.

希望有所帮助:)

这篇关于网络能部署软件包地方议会目标服务器的GAC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆