gpt4 book ai didi

msbuild - 如何使用msbuild删除所有文件和文件夹

转载 作者:行者123 更新时间:2023-12-02 03:31:01 24 4
gpt4 key购买 nike

如何删除给定路径中的所有文件和文件夹?

我尝试过此操作,但无法选择目录。

<Target Name="CleanSource" Condition="$(path)!=''">

<Message Text="path=$(path)"/>

<ItemGroup>
<fileToDelete Include="$(path)\**\*.*" />
<directoryToDelete Include="$(path)\**\" /><!these doest not select any directory at all-->
</ItemGroup>

<Message Text="file to delete:@(fileToDelete)"/>
<Message Text="directory to delete:@(directoryToDelete)"/>

<Delete Files="@(fileToDelete)" />
<Message Text="file effectively deleted:@(DeletedFiles)"/>
<RemoveDir Directories="@(directoryToDelete)" />
<Message Text="Directory effectively deleted:@(RemovedDirectories)"/>

</Target>

最佳答案

RemoveDir task删除指定的目录及其所有文件和子目录。您不必先删除文件和子目录。只需将目录名称传递给RemoveDir即可。

   <ItemGroup>
<DirsToClean Include="work" />
</ItemGroup>
<Target Name="CleanWork">
<RemoveDir Directories="@(DirsToClean)" />
</Target>

关于msbuild - 如何使用msbuild删除所有文件和文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5080856/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com