4

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 Bundle target, only the %(BuildArtifacts.FullPath) gets extracted, %(BuildArtifacts.FullPath) is ignored when the scripts executes.

The command looks like this when executing:

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 is not there, if I hard code the paths or just the destination path it all works. Any suggestion on what I am doing wrong here?

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

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

and now it's working :)

4

2 回答 2

2

我设法解决了这个问题。我已经用解决方案更新了问题。

我删除了最后一部分 WorkingDirectory="C:\Windows\" 并将脚本更改为:

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

现在它正在工作:)

于 2012-05-13T09:14:55.017 回答
0

您需要执行两次 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>
于 2012-05-09T23:04:54.433 回答