Skip to content

Commit

Permalink
Normalize RAR output paths (#6533)
Browse files Browse the repository at this point in the history
Fixes #6501

### Context
RAR can output paths not in their canonical forms. This allows for there to be multiple identical paths, only distinguished by extra directory separator characters, for example, which can lead to duplicate work or failing to find paths in a cache.

### Changes Made
This normalizes all paths output by RAR, ensuring any given path is in its canonical form.
  • Loading branch information
Forgind committed Jul 19, 2021
1 parent fa6868b commit 3e71818
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/Tasks/AssemblyDependency/Reference.cs
Expand Up @@ -513,6 +513,13 @@ internal string FullPath
}
}

internal void NormalizeFullPath()
{
_fullPath = FileUtilities.NormalizePath(_fullPath);
_fullPathWithoutExtension = null;
_directoryName = null;
}

/// <summary>
/// The directory that this assembly lives in.
/// </summary>
Expand Down
12 changes: 11 additions & 1 deletion src/Tasks/AssemblyDependency/ReferenceTable.cs
Expand Up @@ -407,6 +407,12 @@ internal void AddReference(AssemblyNameExtension assemblyName, Reference referen
}
}

if (reference.FullPath.Length > 0 && ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_0))
{
// Saves effort and makes deduplication possible downstream
reference.NormalizeFullPath();
}

References[assemblyName] = reference;
}

Expand Down Expand Up @@ -1337,7 +1343,11 @@ out userRequestedSpecificFile
// If the path was resolved, then specify the full path on the reference.
if (resolvedPath != null)
{
if (!Path.IsPathRooted(resolvedPath))
if (ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_0))
{
resolvedPath = FileUtilities.NormalizePath(resolvedPath);
}
else if (!Path.IsPathRooted(resolvedPath))
{
resolvedPath = Path.GetFullPath(resolvedPath);
}
Expand Down

0 comments on commit 3e71818

Please sign in to comment.