wixtoolset / issues

WiX Toolset Issues Tracker
http://wixtoolset.org/
129 stars 36 forks source link

Wix.exe deletes its own output folder if it's a symlink #7688

Open vikukush opened 1 year ago

vikukush commented 1 year ago

If this issue is a bug:

I am hitting a problem with wix.exe method of cleanup of temporary files. What I see in Procmon is that wix.exe cleans up temporary files and then tries to recursively delete all non-empty folders. image Wix.exe relies on OS to return 145 "Not empty" error code to know when to stop trying to delete. The problem happens when you output to a symlink folder. If you try to delete symlinked folder, it won't return "not empty" error code and will instead successfully remove the symlink, leaving all files intact in symlink's source folder. On the image above, obj\release is an output folder.

Repro steps:

Actual:

Expected:

vikukush commented 1 year ago

Workaround I'm using to put the output one folder deeper preventing symlink from being deleted.

  <Target Name="PatchOutputPath" AfterTargets="AssignTargetPaths">
  <!-- wix.exe will delete its own output folder if it's a symlink, this fails only in CloudBuild https://github.com/wixtoolset/issues/issues/7688
       Patch output path to be one folder deeper than $(IntermediateOutputPath) -->
    <ItemGroup>
      <CultureGroup Remove="@(CultureGroup)" />
      <CultureGroup Include="en-US" >
        <OutputSuffix>en-US</OutputSuffix>
        <OutputFolder>en-US\</OutputFolder>
      </CultureGroup>
    </ItemGroup>
    <PropertyGroup>
      <IntermediateOutputPath>$(IntermediateOutputPath)en-US\</IntermediateOutputPath>
    </PropertyGroup>
  </Target>