我正在尝试使用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
外,所有文件和文件夹都被删除有人可以帮我解决这个问题吗?