Following code illustrates a way to refresh the document content using an msbuild project:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <UsingTask AssemblyFile="$(MSBuildProjectDirectory)\TestPlanWordWriter.Build.dll" TaskName="TestPlanWordWriter.Build.RefreshDocumentTask"></UsingTask>

  <Target Name="Build">
    <Message Text="Project File Directory = $(MSBuildProjectDirectory)" />
    <Message Text="CollectionUri = $(CollectionUri)" />
    <Message Text="TeamProject = $(TeamProject)" />
    <Message Text="OutDir = $(OutDir)" />

    <RefreshDocumentTask
      ProjectName="$(TeamProject)"
      CollectionUri="$(CollectionUri)"
      InputDocumentFile="$(MSBuildProjectDirectory)\SampleTestPlanAndResults.docx"
      OutputDirectory="$(OutDir)"
      OutputFileName="SampleTestPlanAndResults.docx"
      SettingsFile="$(MSBuildProjectDirectory)\TestPlanWordSettings.xml" >
    </RefreshDocumentTask>

  </Target>
 
</Project>

If you want to use this code in a Team Build 2010 build definition you could insert a MSBuild workflow activity in the build definition template and assign following value in CommandLineArguments property:

String.Format("/p:TeamProject=""{0}"" /p:CollectionUri=""{1}"" {2}", BuildDetail.TeamProject, Workspace.VersionControlServer.TeamProjectCollection.Uri.AbsoluteUri, MSBuildArguments)

In order to correctly execute this task you will need to export render settings using the add-in and copy the settings file in the same directory of the msbuild project file along with following dlls:

  • TestPlanWordWriter.Build.dll
  • TestPlanWordWriter.Common.dll
  • DocumentFormat.OpenXml.dll (OpenXml 2.0)

Last edited Apr 3, 2011 at 9:00 PM by luisj, version 12

Comments

No comments yet.