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 を除くすべてのファイルとフォルダーが削除されます。
誰でもこの問題を解決するのを手伝ってもらえますか?