views:

190

answers:

1

My project's manager assigned me to maintain the builds, but it's my first contact with MSBuild, so things are being somewhat hard, as most first contacts. :)
I've been struggling to get MSBuild/Team Build to copy some files to my project's "bin" folder, but had no sucess until now.
The files are kept on a folder that we use as a repository for dependencies and adapters, since we need to be able to compile solutions independently from each other, so all necessary files are already there when MSBuild starts to work and evaluates the ItemGroup. My last try was to call the copy task on a "BeforeDropBuild" target, like this:

<Target Name="BeforeDropBuild">
  <Delete Files="@(DebugPoints)" ContinueOnError="true"></Delete>
  <Copy SourceFiles="@(Adapters)" DestinationFolder="$(TargetDir)" ContinueOnError="true"></Copy>
</Target>

I'm already working on this for some time, since it's basically all that's left for me to complete this build, so I already tried quite a number of different approaches, and none gave me the expected result.

Some of the thinhs I tried were:
- "DestinationFolder" with the full path as value;
- Copying files after dropping the build;
- Copying files on "AfterBuild" Target;

But all of them seemed to result the same: not even an entry of the failed attempt on the BuildLog to help me finding out where I'm wrong. Like the code is now, it gives me even logs of pdb files it can't exclude in some other folders, but no mention to copy attempts, like this one:

Target BeforeDropBuild:
    Deleting file "D:\blablabla\filepath\file.pdb".
MSBUILD : warning MSB3061: Unable to delete file "D:\blablabla\filepath\file.pdb". Access to the path 'D:\blablabla\filepath\file.pdb' is denied.
The previous error was converted to a warning because the task was called with ContinueOnError=true.
Build continuing because "ContinueOnError" on the task "Delete" is set to "true".

Done building target "BeforeDropBuild" in project "TFSBuild.proj".
This seems to be a quite basic problem, but I'm all out of ideas, not even search helped me on this (which also leads me to think that it's REALLY basic).

Edit:

<Target Name="AfterDropBuild">
    <CreateItem Include="$(AdaptersFolder)\Adapter*.dll">
        <Output ItemName="Adaptadores" TaskParameter="Include"/>
    </CreateItem>
    <CreateProperty Value="$(DropLocation)\$(BuildNumber)\%(ConfigurationToBuild.FlavorToBuild)">
        <Output ItemName="ReleaseFolder" TaskParameter="Value"/>
    </CreateProperty>
    <Copy DestinationFolder="$(ReleaseFolder)" SourceFiles="@(Adaptadores)" ContinueOnError="true"></Copy>
    <OnError ExecuteTargets="Error"/>
</Target>

Another unsucessful try. That was not the right directory, anyway, but again, no files were copied and there's not even mention of the AfterDropBuild target on the log files.

A: 

For some reason it wasn't getting the files as expected.
I don't remember if it was like this, maybe was just an error in the syntax or so. Here is how I made it now:

<Target Name="AfterDropBuild">
    <CreateItem Include="$(AdaptersFolder)\AdapterModule.*.dll">
        <Output ItemName="Adapters" TaskParameter="Include"/>
    </CreateItem>
    <Copy DestinationFolder="$(DropBuildAdapterPath)"
      SourceFiles="@(Adapters)" ContinueOnError="true"></Copy>
    <OnError ExecuteTargets="Error"/>
</Target>

This seems to be valid also to files created during the build, since it creates the item (and therefore, validates the list) just after everything was built and copied to drop location and the files are kept on the build path until a new build starts.

wintermute