0

Say I have a project structure with 3 applications:

├───app1
├───app2
├───app3

I want to have an msbuild task to copy the relevant output of each application to a separate deployment location

deploy\app1\<app1.output>
deploy\app2\<app2.output>
deploy\app3\<app3.output>

The script below does the following instead:

deploy\app1\<app1.output> + <app2.output> + <app3.output>
deploy\app2\<app1.output> + <app2.output> + <app3.output>
deploy\app3\<app1.output> + <app2.output> + <app3.output>

I know there is something wrong with the batching, but I cannot figure out how to fix it. Any ideas where I've got it wrong?

<Target Name="Deploy">
    <!-- Ensure the target home exists -->
    <MakeDir Directories="$(DeployPath)" />

    <!-- Select artefacts -->
    <ItemGroup>
        <ProjectPath Include="%(Project.BuildOutput)" />
        <ArtefactSource Include="%(ProjectPath.RootDir)%(ProjectPath.Directory)**\*.*" />
    </ItemGroup>

    <!-- copy files to respective artefact location -->
    <Copy SourceFiles="@(ArtefactSource)" DestinationFolder="$(DeployPath)\%(Project.Identity)"
         Condition="'%(Project.CanDeploy)' AND '%(Project.TestWasRun)' != 'Error'" />
</Target>

1 Answers1

0

I found the solution, based on the following SO post: How can I use MSBuild Copy Task to Copy To Multiple Destination Folders?

My problem was not having an 'Outputs' attribute. Target batching (what I needed) only works when this is in place.

So, I modified the target from:

<Target Name="Deploy">

to

<Target Name="Deploy" Outputs="%(Project.Identity)">

and all was good.

Community
  • 1
  • 1