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

[release/6.0] Work around for UriFormatException caused by \\?\ prefix in the path #71452

Merged
merged 5 commits into from
Aug 11, 2022
Merged
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
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent);netstandard2.0;net461-windows</TargetFrameworks>
<!-- opt-out of trimming until it works https://github.com/dotnet/runtime/issues/49062 -->
<SetIsTrimmable>false</SetIsTrimmable>
<NoWarn>$(NoWarn);CA1847</NoWarn>
<IsPackable>true</IsPackable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<ServicingVersion>1</ServicingVersion>
<PackageDescription>Provides types that support using configuration files.

Commonly Used Types:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,7 @@ private ClientConfigPaths(string exePath, bool includeUserConfig)
if (exeAssembly != null && !isSingleFile)
{
HasEntryAssembly = true;

// The original .NET Framework code tried to get the local path without using Uri.
// If we ever find a need to do this again be careful with the logic. "file:///" is
// used for local paths and "file://" for UNCs. Simply removing the prefix will make
// local paths relative on Unix (e.g. "file:///home" will become "home" instead of
// "/home").
string configBasePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, exeAssembly.ManifestModule.Name);
Uri uri = new Uri(configBasePath);

Debug.Assert(uri.IsFile);
ApplicationUri = uri.LocalPath;
ApplicationUri = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, exeAssembly.ManifestModule.Name);
}
else
{
Expand Down Expand Up @@ -258,7 +248,6 @@ private static string GetTypeAndHashSuffix(string exePath, bool isSingleFile)
if (assembly != null && !isSingleFile)
{
AssemblyName assemblyName = assembly.GetName();
Uri codeBase = new Uri(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, assembly.ManifestModule.Name));

try
{
Expand All @@ -271,7 +260,7 @@ private static string GetTypeAndHashSuffix(string exePath, bool isSingleFile)
{
typeName = StrongNameDesc;
}
else
else if (Uri.TryCreate(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, assembly.ManifestModule.Name), UriKind.Absolute, out Uri codeBase))
{
try
{
Expand Down