wixproj/msbuild 程序在解决方案树中自动创建不需要的文件夹

wixproj/msbuild program creating automatically unwanted folder in the solution tree

我想从部署文件夹中删除文件夹。 我正在使用 removedir 任务。

<ItemGroup>
  <FolderToExcludefromDeploymentFolder Include="$(SourceDir)\Support" />
</ItemGroup>
<Target Name="BeforeBuild" BeforeTargets="Build">
  <RemoveDir Condition="Exists('$(sourceDir)\Support')" Directories="@(FolderToExcludefromDeploymentFolder)" />
</Target>

在那种情况下,我会在解决方案树中得到一个文件夹。

在尝试删除文件夹时出现此错误,项目组元素将自动删除。

我该如何解决这个问题?

我可以解决此问题的唯一方法是将所有有问题的属性移动到 BeforeBuild 目标并将它们设置为 DefineConstants。

<Target Name="BeforeBuild">
<PropertyGroup>
  <SourceDir>$(MSBuildProjectDirectory)..\..\..\Example</SourceDi>
  <FolderToExclude>$(MSBuildProjectDirectory)..\..\..\Example\Support</FolderToExclude>
  <DefineConstants>$(DefineConstants);SourceDir=$(SourceDir);FolderToExclude=$(FolderToExclude)</DefineConstants>
</PropertyGroup>
<RemoveDir Condition="Exists('$(sourceDir)\Support')" Directories="@(FolderToExclude)" />
</Target> 

这个解决方案对我有用,但没有找到背后的原因。