0

I have a dependency replication scheme setup in our TFS environment based on http://geekswithblogs.net/jakob/archive/2009/03/05/implementing-dependency-replication-with-tfs-team-build.aspx.

This uses the CompilationOutputs item group to get the built DLL files and branch/merge them into dependent projects. My problem is that the CompilationOutputs item group only contains the DLLs, and I'd like to also include the XML documentation files, so I can get intellisense documentation tips when using these libraries. Is there a different item group that contains these, or a different approach? Do I need to manually find the xml files and add them to an item group?

We're on TFS 2010 now, so if there's something new there, we can try to take advantage of it (though it'd be nice if I didn't have to convert this whole scheme to use a Workflow process...)

bdukes
  • 152,002
  • 23
  • 148
  • 175

1 Answers1

1

According to the article you copy and checkin the outputs:

<Copy SourceFiles="@(CompilationOutputs)" DestinationFolder="$(ReplicateSourceFolder)"/>
<Exec Command="$(TF) checkin /comment:&quot;Checking in file from build&quot; &quot;$(ReplicateSourceFolder)&quot; /recursive"/>

Couldn't you add a second copy line before the checkin to copy the xml files using the metadata?

<Copy SourceFiles="%(CompilationOutputs.RootDir)%(CompilationOutputs.Directory)\%(CompilationOutputs.Filename).xml" DestinationFolder="$(ReplicateSourceFolder)"/>

Here is another option using an inline task that builds another item group changing the extension so that it only adds doc files that actually exist:

 <Target Name="Test">

    <ChangeExtension InputFiles="@(CompilationOutputs)" Extension=".xml">
      <Output TaskParameter="OutputFiles" ItemName="DocFiles" />
    </ChangeExtension>

    <Copy SourceFiles="@(CompilationOutputs)" DestinationFolder="$(ReplicateSourceFolder)"/>
    <Copy SourceFiles="@(DocFiles)" DestinationFolder="$(ReplicateSourceFolder)"/>
  </Target>

  <UsingTask TaskName="ChangeExtension" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
    <ParameterGroup>
      <InputFiles ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true"/>
      <Extension ParameterType="System.String" Required="true"/>
      <OutputFiles ParameterType="Microsoft.Build.Framework.ITaskItem[]" Output="true"/>
    </ParameterGroup>
    <Task>
      <Code Type="Fragment" Language="cs">
        <![CDATA[
      if (InputFiles.Length > 0)
      {
        List<TaskItem> results = new List<TaskItem>();
        for (int i = 0; i < InputFiles.Length; i++)
        {
          ITaskItem item = InputFiles[i];
          string path = item.GetMetadata("FullPath");
          string docfile = Path.ChangeExtension(path, Extension);
          if (File.Exists(docfile))
          {
            results.Add(new TaskItem(docfile));
          }
        }
        OutputFiles = results.ToArray();
      }
        ]]>
      </Code>
    </Task>
  </UsingTask>
Brian Walker
  • 8,658
  • 2
  • 33
  • 35
  • This looks like it should work (I don't have XML files generated for all projects, so I'm using the second approach). However, it looks like the UpgradeTemplate.xaml workflow that is being used by Team Build 2010 to run the build runs it as MSBuild 3.5, because I'm getting "error MSB4067: The element `` beneath element `` is unrecognized." – bdukes Dec 28 '10 at 20:09
  • Having said that, I found the following in the log, which looks like it's calling the 4.0 version: `C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe /nologo /noconsolelogger "C:\Builds\1\project\build\BuildType\TFSBuild.proj" /m:1 "@C:\Builds\1\project\build\BuildType\TfsBuild.rsp"` – bdukes Dec 28 '10 at 20:11
  • What is the ToolsVersion attribute set to in your TFSBuild.proj. If it is set to 3.5 I see the same problem. Setting it to 4.0 got past it. The other option is to create the custom task as a separate assembly and include it that way. – Brian Walker Dec 28 '10 at 20:38