Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit d7eb8d1

Browse files
committed
Normalize MapProjectPath / MapHostAbsolutePath so they return project paths in different apps
1 parent 68d51b9 commit d7eb8d1

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/ServiceStack.Text/PathUtils.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,45 @@ public static string MapAbsolutePath(this string relativePath, string appendPart
1818
}
1919

2020
/// <summary>
21-
/// Maps the path of a file in the context of a VS project
21+
/// Maps the path of a file in the context of a VS project in a Consle App
2222
/// </summary>
2323
/// <param name="relativePath">the relative path</param>
2424
/// <returns>the absolute path</returns>
2525
/// <remarks>Assumes static content is two directories above the /bin/ directory,
2626
/// eg. in a unit test scenario the assembly would be in /bin/Debug/.</remarks>
2727
public static string MapProjectPath(this string relativePath)
2828
{
29-
var mapPath = MapAbsolutePath(relativePath, string.Format("{0}..{0}..", PclExport.Instance.DirSep));
30-
return mapPath;
29+
var sep = PclExport.Instance.DirSep;
30+
#if !NETSTANDARD1_1
31+
return PclExport.Instance.MapAbsolutePath(relativePath, $"{sep}..{sep}..");
32+
#else
33+
return PclExport.Instance.MapAbsolutePath(relativePath, $"{sep}..{sep}..{sep}..");
34+
#endif
3135
}
3236

3337
/// <summary>
34-
/// Maps the path of a file in a self-hosted scenario
38+
/// Maps the path of a file in the bin\ folder of a self-hosted scenario
3539
/// </summary>
3640
/// <param name="relativePath">the relative path</param>
3741
/// <returns>the absolute path</returns>
3842
/// <remarks>Assumes static content is copied to /bin/ folder with the assemblies</remarks>
3943
public static string MapAbsolutePath(this string relativePath)
4044
{
41-
var mapPath = MapAbsolutePath(relativePath, null);
42-
return mapPath;
45+
return PclExport.Instance.MapAbsolutePath(relativePath, null);
4346
}
4447

4548
/// <summary>
46-
/// Maps the path of a file in an Asp.Net hosted scenario
49+
/// Maps the path of a file in an ASP.NET hosted scenario
4750
/// </summary>
4851
/// <param name="relativePath">the relative path</param>
4952
/// <returns>the absolute path</returns>
5053
/// <remarks>Assumes static content is in the parent folder of the /bin/ directory</remarks>
5154
public static string MapHostAbsolutePath(this string relativePath)
5255
{
56+
var sep = PclExport.Instance.DirSep;
5357
#if !NETSTANDARD1_1
54-
return PclExport.Instance.MapAbsolutePath(relativePath, $"{PclExport.Instance.DirSep}..");
58+
return PclExport.Instance.MapAbsolutePath(relativePath, $"{sep}..");
5559
#else
56-
var sep = PclExport.Instance.DirSep;
5760
return PclExport.Instance.MapAbsolutePath(relativePath, $"{sep}..{sep}..{sep}..");
5861
#endif
5962
}

0 commit comments

Comments
 (0)