我创建了将文件从一个文件夹复制到另一个文件夹的示例(使用msbuild)。如果文件被移动,我会在复制后尝试检查吗?但消息仍然显示,文件没有移动。但是当我在文件夹上看到文件移动成功时。那它是如何解决的?
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PathPackage>C:\Users\test\Desktop\test\1\*.txt</PathPackage>
<Files>C:\Users\test\Desktop\test\2\*.*</Files>
</PropertyGroup>
<ItemGroup>
<Packages Include="$(PathPackage)"/>
<FilesOnFolder Include="$(Files)"/>
</ItemGroup>
<Target Name="B">
<Message Importance="normal" Text="Package before copy:@(Packages)"/>
<CreateItem Include="@(Packages)">
<Output TaskParameter="Include" ItemName="FilesToMove" />
</CreateItem>
<Copy
SourceFiles="@(Packages)"
DestinationFolder="C:\Users\test\Desktop\test\2"
/>
<Delete Files="@(Packages)" />
<Message Importance="normal" Text="Package after package:@(Packages)"/><!--It's full! -->
<Message Importance="normal" Text="Destination Folder:@(FilesOnFolder)"/> <!--It's empty! -->
</Target>
</Project>
答案 0 :(得分:1)
问题出在ItemGroup中。它需要写入目标。