我正在尝试使用 msbuild 删除一些文件和文件夹,但不包括少数文件。
<PropertyGroup>
<SolutionName>TestProject</SolutionName>
<SolutionFileName>$(MSBuildProjectDirectory)/$(SolutionName).sln</SolutionFileName>
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<BuildVersion Condition="'$(BuildVersion)' == ''">1.0.0.0</BuildVersion> <BuildTargetFolder>$(MSBuildProjectDirectory)\..\..\TestProjectBuild</BuildTargetFolder>
<OutputPath>$(BuildTargetFolder)\Builds\$(Configuration)\TestProject - $(BuildVersion)</OutputPath>
</PropertyGroup>
<Target Name="CleanDirExludeFinalOutput">
<ItemGroup>
<!-- Item to get all files recursively in the DeleteRoot folder -->
<FilesToDelete Include="$(OutputPath)\**\*.*" Exclude="$(OutputPath)\**\*.msi;$(OutputPath)\**\*.exe"/>
<!-- Item to get all folders from the files to be deleted -->
<FoldersToDelete Include="%(FilesToDelete.RootDir)%(FilesToDelete.Directory)" Exclude="$(OutputPath)"/>
</ItemGroup>
<!-- Display what will be deleted -->
<Message Text=" # @(FilesToDelete)" Importance="high" />
<Message Text=" # @(FoldersToDelete)" Importance="high" />
<!-- Delete the files -->
<Delete Files="@(FilesToDelete)" Condition=" $(OutputPath)!=''" ContinueOnError="true"/>
<!-- Remove the folders -->
<RemoveDir Directories="@(FoldersToDelete)" Condition="$(OutputPath)!=''" />
</Target>
现在,当我尝试使用 VisualStudio2010 CommandPrompt 中的 msbuild 命令运行上述脚本时,我看到所有文件都已删除。我不想删除 TestProject.msi,setup.exe。
如果我设置,上述工作正常
<BuildTargetFolder>C:\temp\TestProjectBuild</BuildTargetFolder>
除 TestProject.msi,setup.exe 之外的所有文件和文件夹都被删除
谁能帮我解决这个问题?