Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Package/build/ReferenceTrimmer.targets
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
<CompilerVisibleProperty Include="EnableReferenceTrimmerDiagnostics"/>
</ItemGroup>

<Target Name="CollectDeclaredReferences" DependsOnTargets="ResolveAssemblyReferences;PrepareProjectReferences" Condition="'$(EnableReferenceTrimmer)' != 'false'">
<Target Name="CollectDeclaredReferences"
DependsOnTargets="ResolveAssemblyReferences;PrepareProjectReferences"
Condition="'$(EnableReferenceTrimmer)' != 'false'"
Inputs="$(MSBuildProjectFullPath);$(ProjectAssetsFile)"
Outputs="$(MSBuildProjectDirectory)\$(IntermediateOutputPath)_ReferenceTrimmer_DeclaredReferences.tsv">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Outputs="$(MSBuildProjectDirectory)\$(IntermediateOutputPath)_ReferenceTrimmer_DeclaredReferences.tsv">
Outputs="$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)_ReferenceTrimmer_DeclaredReferences.tsv'))">

<PropertyGroup>
<_ReferenceTrimmerDeclaredReferencesFile>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)_ReferenceTrimmer_DeclaredReferences.tsv'))</_ReferenceTrimmerDeclaredReferencesFile>
<_ReferenceTrimmerUsedReferencesFile>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)_ReferenceTrimmer_UsedReferences.log'))</_ReferenceTrimmerUsedReferencesFile>
Expand Down
3 changes: 3 additions & 0 deletions src/Tasks/CollectDeclaredReferencesTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,9 @@ private static void SaveDeclaredReferences(IReadOnlyList<DeclaredReference> decl
string existing = File.ReadAllText(filePath);
if (string.Equals(existing, newContent, StringComparison.OrdinalIgnoreCase))
{
// Touch the file so that MSBuild's Inputs/Outputs incrementality check
// sees a fresh timestamp and can skip the target on subsequent builds.
File.SetLastWriteTimeUtc(filePath, DateTime.UtcNow);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the whole point of the if check is not to touch the timestamp if the file is identical, so this line should be reverted.

return;
}
}
Expand Down