3

I saw this S.O question and have a similar requirement. This is what I have in a .targets file -

    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup Condition="$(TeamBuildOutDir) != '' ">
        <OutputPath>$(TeamBuildOutDir)\Assemblies</OutputPath>                 
    </PropertyGroup>

How can I output to multiple folders? e.g.- $(TeamBuildOutDir)\Assemblies2

TIA

Thanks Nick, The copy/paste mucked it up. This is what I tried -

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="$(TeamBuildOutDir) != '' ">
 <OutputPath>$(TeamBuildOutDir)\Assemblies</OutputPath>                   
</PropertyGroup>
<Target Name="AfterBuild">
 <Copy SourceFiles="$(OutputPath)\**\*.*" DestinationFolder="$(TeamBuildOutDir)\Assemblies2" />
</Target>
</Project>

I've also tried -

 <Copy SourceFiles="$(OutputPath)\***\*.*" DestinationFolder="$(TeamBuildOutDir)\Assemblies2" />

and -

 <Copy SourceFiles="$(OutputPath)\***\*.*" DestinationFolder="$(TeamBuildOutDir)\" />

in case the directory not being present caused an issue but still no luck.

Updated 7/28. Tried this but doesn't work still (no errors but the files are not present in the output directory. They are present in the Assemblies folder so I know the targets file is being triggered.) -

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="$(TeamBuildOutDir) != '' ">
 <OutputPath>$(TeamBuildOutDir)\Assemblies</OutputPath>                   
</PropertyGroup>
<Target Name="AfterBuild">
 <CreateItem Include="$(OutputPath)\**\*.*">
     <Output ItemName="Outfiles" TaskParameter="Include" />
 </CreateItem>
 <Copy SourceFiles="@(Outfiles)" DestinationFiles="@(Outfiles->'$(TeamBuildOutDir)\%(relativedir)%(Filename)%(Extension)')" SkipUnchangedFiles="false" />
</Target>
</Project>
Community
  • 1
  • 1
Pete
  • 169
  • 2
  • 14

1 Answers1

0

You create an AfterBuild target with a copy task the contents of $(OutputPath) to $(TeamBuildOutDir)\Assemblies2.

<Target Name="AfterBuild">
 <Copy SourceFiles="$(OutputPath)\**\*.*" DestinationFolder="$(TeamBuildOutDir)\Assemblies2" />
</Target>

Edit, updating this to include a test message, and include a "DependsOnTarget" attribute to see if we can get this to occur after the build process...

<Target Name="AfterBuild" DependsOnTarget="Build">
 <Message Text="**** TEST **** " Importance="high" />
 <Copy SourceFiles="$(OutputPath)\**\*.*" DestinationFolder="$(TeamBuildOutDir)\Assemblies2" />
</Target>
Nicodemeus
  • 4,005
  • 20
  • 23
  • Thanks Nick! I'll give it try and report back. – Pete Jul 10 '13 at 02:26
  • I tried this but it didn't work - $(TeamBuildOutDir)\Assemblies – Pete Jul 15 '13 at 15:57
  • Note how your SourceFiles location is "**." when it should be "**\*.*". – Nicodemeus Jul 16 '13 at 20:49
  • No luck Nick... I updated the qts since the code isn't getting formatted in the comments... any suggestions? – Pete Jul 23 '13 at 19:42
  • Ah, it appears it was interpreting the backslash as an escape character, so my above should have been something like "** \\*.*" – Nicodemeus Jul 24 '13 at 00:17
  • If you're not getting an error, just not seeing the files dropped in the new location, add a <Message Text="Test" Importance="High" /> to see if the target is firing. Next use a MakeDir task to create the folder. If none of those work and you are getting an error, post that error. – Nicodemeus Jul 24 '13 at 00:20
  • Thanks Nick, I should've caught that I'll try your suggestion and let you know. With the code I tried earlier I wasn't getting an error but I know the target was firing, because if I reverted to a single directory in the targets it worked fine and when I tried to move things around I got an error. Thanks for your help. – Pete Jul 28 '13 at 05:09
  • So it turns out that is what I've tried already... it doesn't throw any errors. I've also updated the question with the other options I tried. Are you sure this is something that tfs build supports with custom targets? – Pete Jul 28 '13 at 15:19
  • Hey Pete! Updated the comment, added a DependsOnTarget to see if we can get this to fire after the default Build target. Do you see that "Test" message? – Nicodemeus Jul 30 '13 at 17:01
  • Thanks Nick... I added the Target tag after PropertyGroup tag and both within the Project tag. After adding that I get this error message in the build - C:\Builds\24\PS\zQuick Test Hybrid Build\Sources\PS MSI\Targets\ConnectionStorageOutDir.targets (5): The attribute "DependsOnTarget" in element is unrecognized. – Pete Aug 02 '13 at 14:06
  • 1
    Update... I added the missing 's' at the end of 'DependsOnTarget' and the error went away. However the Test message did not show up nor did it copy the output to second folder. And I did try moving the tag before/after the tag. – Pete Aug 02 '13 at 15:14