Skip to content

Commit a5695e1

Browse files
authored
Revert "Allow FileWritesShared to be tracked and cleaned with an opt-in flag" (#12239)
1 parent 2429db9 commit a5695e1

File tree

1 file changed

+15
-32
lines changed

1 file changed

+15
-32
lines changed

src/Tasks/Microsoft.Common.CurrentVersion.targets

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5761,44 +5761,27 @@ Copyright (C) Microsoft Corporation. All rights reserved.
57615761
<ItemGroup>
57625762
<_CleanPriorFileWrites Include="@(_CleanUnfilteredPriorFileWrites)" Exclude="@(_ResolveAssemblyReferenceResolvedFilesAbsolute)"/>
57635763
</ItemGroup>
5764-
5765-
<PropertyGroup>
5766-
<!--
5767-
If set, FileWritesShareable will be located under the OutDir and IntermediateOutputPath.
5768-
If not set, FileWritesShareable will be located only under the MSBuildProjectDirectory.
5769-
5770-
The default layout of projects is that everything particular to the project is
5771-
located under the MSBuildProjectDirectory, so it's considered safe to track/delete those.
5772-
The assumption was that anything outside the project's directory is shared between multiple projects
5773-
and should not be deleted by the Clean target.
5774-
5775-
However, this is not always the case. The .NET SDK has a feature called Artifacts Layout
5776-
where project outputs are tracked in _project-specific_ locations under a root that is
5777-
outside of the project directory. In such cases, we need to be able to track FileWritesShareable
5778-
even from those locations.
5779-
-->
5780-
<TrackFileWritesShareableOutsideOfProjectDirectory Condition=" '$(TrackFileWritesShareableOutsideOfProjectDirectory)' == '' ">false</TrackFileWritesShareableOutsideOfProjectDirectory>
5781-
</PropertyGroup>
5782-
5783-
<!-- Even if we don't allow cleaning filewrites from outside of the project bubble, we should still include FileWritesShareable that are inside the bubble -->
5784-
<FindUnderPath Condition="!$(TrackFileWritesShareableOutsideOfProjectDirectory)" Path="$(MSBuildProjectDirectory)" Files="@(FileWritesShareable)" UpdateToAbsolutePaths="true">
5764+
<!--
5765+
Of shareable files, keep only those that are in the project's directory.
5766+
We never clean shareable files outside of the project directory because
5767+
the build may be to a common output directory and other projects may need
5768+
them.
5769+
5770+
Only subtract the outputs from ResolveAssemblyReferences target because that's the
5771+
only "Resolve" target that tries to resolve assemblies directly from the output
5772+
directory.
5773+
-->
5774+
<FindUnderPath Path="$(MSBuildProjectDirectory)" Files="@(FileWritesShareable)" UpdateToAbsolutePaths="true">
57855775
<Output TaskParameter="InPath" ItemName="FileWrites"/>
57865776
</FindUnderPath>
57875777

5788-
<!-- Find all files in the final output directory. Use separate item includes for Files based on condition so we don't create a whole new
5789-
item list unnecessarily -->
5790-
<FindUnderPath Path="$(OutDir)" Files="@(FileWrites)" UpdateToAbsolutePaths="true" Condition="!$(TrackFileWritesShareableOutsideOfProjectDirectory)">
5791-
<Output TaskParameter="InPath" ItemName="_CleanCurrentFileWritesInOutput"/>
5792-
</FindUnderPath>
5793-
<FindUnderPath Path="$(OutDir)" Files="@(FileWrites);@(FileWritesShareable)" UpdateToAbsolutePaths="true" Condition="$(TrackFileWritesShareableOutsideOfProjectDirectory)">
5778+
<!-- Find all files in the final output directory. -->
5779+
<FindUnderPath Path="$(OutDir)" Files="@(FileWrites)" UpdateToAbsolutePaths="true">
57945780
<Output TaskParameter="InPath" ItemName="_CleanCurrentFileWritesInOutput"/>
57955781
</FindUnderPath>
57965782

5797-
<!-- Find all files in the intermediate output directory. Same as above, use Conditions to prevent new item list writes -->
5798-
<FindUnderPath Path="$(IntermediateOutputPath)" Files="@(FileWrites)" UpdateToAbsolutePaths="true" Condition="!$(TrackFileWritesShareableOutsideOfProjectDirectory)">
5799-
<Output TaskParameter="InPath" ItemName="_CleanCurrentFileWritesInIntermediate"/>
5800-
</FindUnderPath>
5801-
<FindUnderPath Path="$(IntermediateOutputPath)" Files="@(FileWrites);@(FileWritesShareable)" UpdateToAbsolutePaths="true" Condition="$(TrackFileWritesShareableOutsideOfProjectDirectory)">
5783+
<!-- Find all files in the intermediate output directory. -->
5784+
<FindUnderPath Path="$(IntermediateOutputPath)" Files="@(FileWrites)" UpdateToAbsolutePaths="true">
58025785
<Output TaskParameter="InPath" ItemName="_CleanCurrentFileWritesInIntermediate"/>
58035786
</FindUnderPath>
58045787

0 commit comments

Comments
 (0)