如何构建Office加载项而不在构建系统上注册它? [英] How to build an Office Add-In without registering it on the build system?

查看:109
本文介绍了如何构建Office加载项而不在构建系统上注册它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用Visual Studio 2008构建Office 2007加载项.我们的构建是通过连续集成服务器(一台计算机)执行的,该服务器在我们检入更改或手动请求更改时进行构建.服务器可以同时执行构建.

我们注意到,当Visual Studio 2008生成Office 2007加载项时,即使未在集成服务器上安装Office,它也会在执行生成的系统上注册它.

有人知道阻止Visual Studio 2008在构建外接程序时对其进行注册的方法吗?

解决方案

假定您的持续集成服务器使用MSBuild来构建Office 2007加载项,一个快速的解决方法是执行一个Build目标,然后执行VSTOClean目标. /p>

您可以通过创建一个控制构建过程的MSBuild项目文件(master.proj)来实现此目标,如以下示例所示:

<Project 
  DefaultTargets="Build" 
  xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
  <PropertyGroup>
    <WorkingDirectory>C:\BASE_DIR\</WorkingDirectory>
  </PropertyGroup>

  <ItemGroup>
    <VstoProject Include = "$(WorkingDirectory)OfficeAddInProject1.csproj"/>
    <VstoProject Include = "$(WorkingDirectory)OfficeAddInProject1.csproj"/>
  </ItemGroup>

  <Target Name="Build">
    <MSBuild Projects="@(VstoProject)" Targets="Build;VSTOClean" />
  </Target>
</Project>

更新: 如果之后的清理工作还不够,您可以通过覆盖属性(VSTO_ProjectType)来停止注册过程.对于Office加载项,此属性设置为 Application ,这将强制进行注册过程.通过将其设置为自定义值,可以禁用注册.这些示例明确列出了要构建的项目,但是您也可以通过指定解决方案文件来测试它们.但是,CI服务器必须直接使用MSBuild而不是VS来执行构建.

<Project 
  DefaultTargets="Build" 
  xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
  <PropertyGroup>
    <WorkingDirectory>C:\BASE_DIR\</WorkingDirectory>
  </PropertyGroup>

  <ItemGroup>
    <VstoProject Include = "$(WorkingDirectory)OfficeAddInProject1.csproj"/>
    <VstoProject Include = "$(WorkingDirectory)OfficeAddInProject1.csproj"/>
  </ItemGroup>

  <Target Name="Build">
    <MSBuild 
        Projects="@(VstoProject)" 
        Targets="Build" 
        Properties="VSTO_ProjectType=Custom" />
  </Target>
</Project>

We are building Office 2007 add-ins using Visual Studio 2008. Our builds are performed via a continuous integration server (one machine) that builds whenever we check in changes or manually request one. The server can perform simultaneous builds.

We noticed that when Visual Studio 2008 builds an Office 2007 add-in, it also registers it on the system performing the build, even though Office isn't installed on the integration server.

Does anyone know of a way to prevent Visual Studio 2008 from registering the Add-in as it builds it?

解决方案

Assuming your continuous integration server is using MSBuild to build the Office 2007 Add-in's a quick workaround will be to execute a Build target followed by a VSTOClean target.

You can achieve this by creating a MSBuild project file (master.proj) that controls the build process as illustrated in the following example:

<Project 
  DefaultTargets="Build" 
  xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
  <PropertyGroup>
    <WorkingDirectory>C:\BASE_DIR\</WorkingDirectory>
  </PropertyGroup>

  <ItemGroup>
    <VstoProject Include = "$(WorkingDirectory)OfficeAddInProject1.csproj"/>
    <VstoProject Include = "$(WorkingDirectory)OfficeAddInProject1.csproj"/>
  </ItemGroup>

  <Target Name="Build">
    <MSBuild Projects="@(VstoProject)" Targets="Build;VSTOClean" />
  </Target>
</Project>

Update: If cleaning after is not enough for you you can stop the registration process by overriding the property (VSTO_ProjectType). For a office add-in this property is set to Application which forces the registration process to take place. By setting it to a custom value you disable the registration. These examples explicitly list which projects to build but you can test them also by specifying a solution file. However the CI server must use MSBuild directly and not VS to perform the builds.

<Project 
  DefaultTargets="Build" 
  xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
  <PropertyGroup>
    <WorkingDirectory>C:\BASE_DIR\</WorkingDirectory>
  </PropertyGroup>

  <ItemGroup>
    <VstoProject Include = "$(WorkingDirectory)OfficeAddInProject1.csproj"/>
    <VstoProject Include = "$(WorkingDirectory)OfficeAddInProject1.csproj"/>
  </ItemGroup>

  <Target Name="Build">
    <MSBuild 
        Projects="@(VstoProject)" 
        Targets="Build" 
        Properties="VSTO_ProjectType=Custom" />
  </Target>
</Project>

这篇关于如何构建Office加载项而不在构建系统上注册它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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