views:

170

answers:

1

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?

+1  A: 

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>
João Angelo
The integration server is using a Visual Studio SLN file to perform the build. It might still be possible to modify the PROJ file; I'll investigate. This solution doesn't really stop the registration though, it just minimizes it's duration. Given that simultaneous builds are occurring, I wonder if this duration would still be too long?
Jason Swager
Added another alternative.
João Angelo
That will work. Thanks!
Jason Swager