views:

1242

answers:

3

Hi

I have this team build target setup to after compile

  <Target Name="AfterCompile">
    <Copy SourceFiles="$(SolutionRoot)\Development_VS2008\MyCompanyName.SharePoint.12" DestinationFolder="c:\testing"></Copy>
  </Target>

I want the folder structure copied from source to destination...

Amazingly I am getting this error

Could not copy the file "C:\TFS\NightlyBuild\Sources\Development_VS2008\MyCompanyName.SharePoint.12\" to the destination file "c:\testing\", because the destination is a folder instead of a file. To copy the source file into a folder, consider using the DestinationFolder parameter instead of DestinationFiles.

As you can see I am indeed using the destinationfolder parameter, does anyone know what I am doing wrong?

+2  A: 

I think it might be just because SourceFiles is a directory rather than the files you want to copy. Try this:

<Target Name="AfterCompile">
    <ItemGroup>
        <FilesToCopy Include="$(SolutionRoot)\Development_VS2008\MyCompanyName.SharePoint.12\**\*.*"/>
    </ItemGroup>

    <Copy SourceFiles="@(FilesToCopy)" DestinationFolder="c:\testing\%(RecursiveDir)"/>
</Target>

HTH, Kent

Kent Boogaart
This kinda works, at least its not failing, but its not retaining the directory stucture in the destinationfolder, any idea how to keep the stucture on the other side?
Michael L
Have updated my post.
Kent Boogaart
A: 

We are experiencing a lot of problems with postbuild xcopy commands. And we decided to avoid xcopy commands.

We are now including the files (which we want to copy) into project, and we are setting copy local property to "Copy if newer" and target directory (directory structure must be same in project)

It helps a lot. Maybe it also fit your situation.

Kaan

I need files copied manually to other locations, I was thinking about using xcopy, and I might try this.
Michael L
+2  A: 

You need something such as this:

<CreateItem Include="someFolder\**\*.*">

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

</CreateItem>

<Copy SourceFiles="@(files)" DestinationFiles="@(files->'C:\folder\%(relativedir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />

Or alternatively I've found the easiest way (if you want to be a bit more stringent about what to include/ exclude) is with some custom MSBuild tasks I've written: http://www.aaron-powell.com/blog.aspx?cat=AaronPowell.MSBuild.Tasks

You provide a source directory, a destination direction (support for network shares is provided) and file names/ extensions to exclude.

It's mainly because Team Build makes a real mess (particularly with web apps) when it run and it's not really possible to use the standard MSBuild copy tasks.

Slace