Skip to content

Commit

Permalink
Using URI file schema for Live Logger hyperlinks (#8702)
Browse files Browse the repository at this point in the history
Some terminal emulators handle `file://` links but not bare paths.
  • Loading branch information
rokonec authored Apr 25, 2023
1 parent 5738af0 commit 662a36f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/MSBuild/LiveLogger/LiveLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,15 @@ private void ProjectFinished(object sender, ProjectFinishedEventArgs e)
// Ignore any GetDirectoryName exceptions.
}

// Generates file:// schema url string which is better handled by various Terminal clients than raw folder name.
string urlString = url.ToString();
if (Uri.TryCreate(urlString, UriKind.Absolute, out Uri? uri))
{
urlString = uri.AbsoluteUri;
}

Terminal.WriteLine(ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword("ProjectFinished_OutputPath",
$"{AnsiCodes.LinkPrefix}{url.ToString()}{AnsiCodes.LinkInfix}{outputPath}{AnsiCodes.LinkSuffix}"));
$"{AnsiCodes.LinkPrefix}{urlString}{AnsiCodes.LinkInfix}{outputPath}{AnsiCodes.LinkSuffix}"));
}
else
{
Expand Down

0 comments on commit 662a36f

Please sign in to comment.