Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vikukush opened this issue Aug 22, 2023 · 1 comment
Open

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

vikukush opened this issue Aug 22, 2023 · 1 comment
Labels
up for grabs No one volunteered to fix the issue. If you are interested, comment with "I want to fix this issue"

Comments

@vikukush
Copy link

vikukush commented Aug 22, 2023

If this issue is a bug:

  • Which version of WiX are you building with?

4.0.1

  • Which version of Visual Studio are you building with (if any)?

17.6

  • Which version of the WiX Toolset Visual Studio Extension are you building with (if any)?

N/A

  • Which version of .NET are you building with?

.Net Framework 4.7.2

  • If the problem occurs when installing your packages built with WiX, what is the version of Windows the package is running on?

N/A

  • Describe the problem and the steps to reproduce it.

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:

  • Create a .wixproj targeting .msi file without localization
  • Delete .wixproj's output folder and replace it with a symlink to some other folder: mklink /D E:\FinOps\pl3\Source\Setup\MSIWix\TraceParser\obj\release E:\FinOps\pl3\Source\Setup\MSIWix\TraceParser\a
  • Build .wixproj

Actual:

  • wix.exe will successfully compile the .msi file and will then wipe the output folder's symlink and recreate it being empty
  • CopyFilesToOutputDirectory target fails to find output file: D:\blah\wixtoolset.sdk\4.0.1\tools\wix.targets(928,5): error MSB3030: Could not copy the file "obj\Release\TraceParser.wixpdb" because it was not found.

Expected:

  • wix.exe deletes only temporary files it created and doesn't touch output directory in any other way
@vikukush
Copy link
Author

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>

@barnson barnson added up for grabs No one volunteered to fix the issue. If you are interested, comment with "I want to fix this issue" and removed triage labels Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
up for grabs No one volunteered to fix the issue. If you are interested, comment with "I want to fix this issue"
Projects
None yet
Development

No branches or pull requests

2 participants