Xcopy with MsBuild

I have a really simple build script that looks like this:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0" DefaultTargets="Bundle">

<ItemGroup>
    <BuildArtifacts Include="..\_buildartifacts" />
    <Application    Include="..\_application" />
</ItemGroup>

<Target Name="Clean">
    <RemoveDir Directories="@(BuildArtifacts)" />
    <RemoveDir Directories="@(Application)" />
</Target>

<Target Name="Init" DependsOnTargets="Clean">
    <MakeDir Directories="@(BuildArtifacts)" />
    <MakeDir Directories="@(Application)" />
</Target>

<Target Name="Bundle" DependsOnTargets="Compile">
    <Exec Command="xcopy.exe %(BuildArtifacts.FullPath) %(Application.FullPath) /e /EXCLUDE:$(MSBuildProjectDirectory)\files_to_ignore_when_bundling.txt" WorkingDirectory="C:\Windows\" />
</Target>

The problem is the purpose of the Bundle, only retrieved %(BuildArtifacts.FullPath), %(BuildArtifacts.FullPath)ignored when running scripts.

The command is as follows:

xcopy.exe C:\@Code\blaj_buildartifacts /e /EXCLUDE:C:\@Code\blaj\files_to_ignore_when_bundling.txt" exited with code 4

As you can see, the destination path does not exist, if I hard-code the paths or only the destination path, it all works. Any suggestion on what I'm doing wrong here?

Update I managed to solve the problem, I deleted the last part, WorkingDirectory="C:\Windows\" and changed the script to this:

<Exec Command="xcopy.exe @(BuildArtifacts) @(Application) /e /EXCLUDE:$(MSBuildProjectDirectory)\files_to_ignore_when_bundling.txt" />

and now it works :)

+3
source share
2 answers

I managed to solve it. I updated the question with a solution.

I removed the last part of WorkDirectory = "C: \ Windows \" and changed the script to this:

 <Exec Command="xcopy.exe @(BuildArtifacts) @(Application) /e /EXCLUDE:$(MSBuildProjectDirectory)\files_to_ignore_when_bundling.txt" />

and now it works :)

+1

xcopy . , . :

<Target Name="Bundle" DependsOnTargets="Compile">
  <Exec Command="xcopy.exe %(BuildArtifacts.FullPath) /e /EXCLUDE:$(MSBuildProjectDirectory)\files_to_ignore_when_bundling.txt" WorkingDirectory="C:\Windows\" />
  <Exec Command="xcopy.exe %(Application.FullPath) /e /EXCLUDE:$(MSBuildProjectDirectory)\files_to_ignore_when_bundling.txt" WorkingDirectory="C:\Windows\" />
</Target>
0

All Articles