Skip to content
Merged
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
21 changes: 20 additions & 1 deletion LibGit2Sharp/GlobalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,26 @@ static GlobalSettings()
{
if (Platform.OperatingSystem == OperatingSystemType.Windows)
{
string managedPath = new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath;
/* Assembly.CodeBase is not actually a correctly formatted
* URI. It's merely prefixed with `file:///` and has its
* backslashes flipped. This is superior to EscapedCodeBase,
* which does not correctly escape things, and ambiguates a
* space (%20) with a literal `%20` in the path. Sigh.
*/
var managedPath = Assembly.GetExecutingAssembly().CodeBase;
if (managedPath == null)
{
managedPath = Assembly.GetExecutingAssembly().Location;
}
else if (managedPath.StartsWith("file:///"))
{
managedPath = managedPath.Substring(8).Replace('/', '\\');
}
else if (managedPath.StartsWith("file://"))
{
managedPath = @"\\" + managedPath.Substring(7).Replace('/', '\\');
}

nativeLibraryPath = Path.Combine(Path.Combine(Path.GetDirectoryName(managedPath), "lib"), "win32");
}

Expand Down