diff --git a/OpenRA.Game/Platform.cs b/OpenRA.Game/Platform.cs index 91f16e9914..61b3d3fa8a 100644 --- a/OpenRA.Game/Platform.cs +++ b/OpenRA.Game/Platform.cs @@ -95,12 +95,24 @@ namespace OpenRA return dir + Path.DirectorySeparatorChar; } - public static string GameDir { get { return AppDomain.CurrentDomain.BaseDirectory; } } + public static string GameDir + { + get + { + var dir = AppDomain.CurrentDomain.BaseDirectory; + + // Add trailing DirectorySeparator for some buggy AppPool hosts + if (!dir.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal)) + dir += Path.DirectorySeparatorChar; + + return dir; + } + } /// Replaces special character prefixes with full paths. public static string ResolvePath(string path) { - path = path.TrimEnd(new char[] { ' ', '\t' }); + path = path.TrimEnd(' ', '\t'); // Paths starting with ^ are relative to the support dir if (path.StartsWith("^", StringComparison.Ordinal)) diff --git a/OpenRA.Test/OpenRA.Game/PlatformTest.cs b/OpenRA.Test/OpenRA.Game/PlatformTest.cs index fe357fa277..58152f043d 100644 --- a/OpenRA.Test/OpenRA.Game/PlatformTest.cs +++ b/OpenRA.Test/OpenRA.Game/PlatformTest.cs @@ -39,6 +39,9 @@ namespace OpenRA.Test Assert.That(Platform.ResolvePath("./testpath"), Is.EqualTo(Path.Combine(gameDir, "testpath"))); + Assert.That(Platform.ResolvePath(Path.Combine(".", "Foo.dll")), + Is.EqualTo(Path.Combine(gameDir, "Foo.dll"))); + Assert.That(Platform.ResolvePath("testpath"), Is.EqualTo("testpath")); }