开发者

How to build an Office Add-In without registering it on the build system?

开发者 https://www.devze.com 2022-12-21 04:48 出处:网络
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

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 S开发者_StackOverflow中文版tudio 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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号