customize tfsbuild.proj to copy files

Hello,

I am having trouble with something that should be really simple. I want my nightly build to copy my website files and the supporting .dlls to my webserver after doing the original "drop". I've tried to do this by using the "AfterDropBuild" target (below)- and the "copy" target that microsoft includes. I DO have the import project statement for the build targets in my tfsbuil.proj- located prior to the target below. When I run the build it seems to completely disregard this target- It doesn't raise any errors- just completes successfully- so I am wondering if this piece is not being picked up at all Right now, I'm just trying to copy these files to a local directory on the build machine- just to see if I can get that to work.

Help appreciated. thanks.

<Target Name="AfterDropBuild">

<Message Text="My target for deployment"/>

<CreateItem Include="$(BinariesRoot)\$(Platfom)\$(Configuration)\*.*" >

<Output ItemName="FilesToCopy" TaskParameter="Include" />

</CreateItem>

<Copy

SourceFiles="@(FilesToCopy)"

DestinationFolder="C:\temp\"

SkipUnchangedFiles="false"

ContinueOnError="false"/>

</Target>




Answer this question

customize tfsbuild.proj to copy files

  • kari0002

    Buck- yes my build compiles the project and copies it to the drop location (which is on the build machine). I was wrong- there is some indication that the build trying to execute my target.

    After CoreDropBuild the log file indicates:

    Target AfterDropBuild:

    My custom target for deployment

    Build succeeded.

    0 Warning(s)

    0 Error(s)

    But it doesn't copy the files the location- is there something wrong with my include statement maybe I am not picking up any files here Shouldn't

    <CreateItem Include="$(BinariesRoot)\$(Platfom)\$(Configuration)\*.*" >

    pick up all the files under Binaries\Mixed Platforms\Release in the build location

    Thank you



  • Leon Bouquiet

    Thanks Aaron-

    Actually, I only want to pick up the files that are located in $(BinariesRoot)\Mixed Platforms\Release\_PublishedWebsites\myWebProj.Web_deploy. I want to grab the web files in this directory- and the bin folder with the .dlls- copy all this exactly as it is- maintaining the directory structure and drop them directly into a directory on another machine. I can't figure out how to arrange my "include" statement to get these files and keep the bin directory - if I use

    Include="$(BinariesRoot)\Mixed Platforms\Release\_PublishedWebsites\Mywebproj.Web_deploy\*.*

    I end up grabbing all of the files plus all of the file in all of the subdirectories and copying them together into the destination directory.



  • Timelapse

    If I understand you correctly, I think you can do:

    Include="$(BinariesRoot)\Mixed Platforms\Release\_PublishedWebsites\Mywebproj.Web_deploy\**\*.*"

    Then, in your copy you can do:

    <Copy SourceFiles="@(FilesToCopy)" DestinationFiles="@(FilesToCopy->'C:\temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    See the MSDN docs on MSBuild Transforms and Well-Known Metadata for more information on this stuff:

    http://msdn2.microsoft.com/en-us/library/ms171476.aspx

    http://msdn2.microsoft.com/en-us/library/ms164313.aspx

    -Aaron



  • Wacha

    Does the build compile your project and copy it to the drop location when you run the build What's in the log file

    Buck



  • Bruno Caponi

    Have you tried using an Item Group instead of the CreateItem element, like this...

    <ItemGroup>
    <FilesToCopy Include="$(BinariesRoot)\$(Platfom)\$(Configuration)\*.*" />
    </ItemGroup>

    I think this is the more common approach. The documentation for the CreateItem task says "Populates item collections with the input items. This allows items to be copied from one list to another." So, I am not sure if it is working as you expect it to.

    Good Luck :)

    Jason


  • hwiz

    yes, that's it exactly. thank you - I appreciate it.

  • Greg B.

    The issue is with your use of $(Platform) and $(Configuration)... My guess is that you saw these in Microsoft.TeamFoundation.Build.targets and are thinking that you can use them in your target the same way they are used in the CoreCompile and CoreTest targets. The trouble is that these properties are not set in the spot where you are attempting to use them.

    Here is how they are used in Microsoft.TeamFoundation.Build.targets:

    * For each PlatformToBuild value and FlavorToBuild value in the OutDirsForConfiguration collection, an <MSBuild> task is called, passing in the properties Configuration = $(FlavorToBuild) and Platform = $(PlatformToBuild). See, for example, the RunTestWithConfiguration target.

    * The properties $(Platform) and $(Configuration) only exist within this child MSBuild "process" (I put that in quotes because an <MSBuild> task does not actually create a new process - see http://msdn2.microsoft.com/en-us/library/z7f65y0d.aspx for more info on this).

    So - there are a couple of approaches you can take:

    (1) You can use the same syntax as the RunTestWithConfiguration target to iterate over the various platform / configuration types.

    (2) You can use wildcards to pick up everything in all of the platform / configuration combinations at once (something like $(BinariesRoot)\**\*.*).

    Hope this all makes sense - let me know if you have further questions and I can provide a more concrete example.



  • customize tfsbuild.proj to copy files