Ensure additional probing paths don't have a trailing slash.

Workaround for https://github.com/dotnet/core-setup/issues/228.
This commit is contained in:
Eric Erhardt 2016-07-26 22:27:25 -05:00
parent ba0f71f5a5
commit 104ca5219d
4 changed files with 22 additions and 3 deletions

View file

@ -56,6 +56,20 @@ namespace Microsoft.DotNet.Tools.Common
return path + trailingCharacter;
}
public static string EnsureNoTrailingSlash(string path)
{
if (!string.IsNullOrEmpty(path))
{
char lastChar = path[path.Length - 1];
if (lastChar == Path.DirectorySeparatorChar || lastChar == '/')
{
path = path.Substring(0, path.Length - 1);
}
}
return path;
}
public static void EnsureParentDirectory(string filePath)
{
string directory = Path.GetDirectoryName(filePath);

View file

@ -281,7 +281,8 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
var additionalProbingPaths = new JArray();
foreach (var packageFolder in _context.LockFile.PackageFolders)
{
additionalProbingPaths.Add(packageFolder.Path);
// DotNetHost doesn't handle additional probing paths with a trailing slash
additionalProbingPaths.Add(PathUtility.EnsureNoTrailingSlash(packageFolder.Path));
}
runtimeOptions.Add("additionalProbingPaths", additionalProbingPaths);

View file

@ -8,6 +8,7 @@ using System.Linq;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.Tools.Common;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
@ -119,7 +120,8 @@ namespace Microsoft.DotNet.Cli.Tasks
runtimeOptions.AdditionalProbingPaths = new List<string>();
}
runtimeOptions.AdditionalProbingPaths.Add(packageFolder.Path);
// DotNetHost doesn't handle additional probing paths with a trailing slash
runtimeOptions.AdditionalProbingPaths.Add(PathUtility.EnsureNoTrailingSlash(packageFolder.Path));
}
}

View file

@ -9,6 +9,7 @@ using System.Runtime.InteropServices;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.InternalAbstractions;
using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.Tools.Common;
using NuGet.Frameworks;
namespace Microsoft.DotNet.Tools.Run
@ -152,7 +153,8 @@ namespace Microsoft.DotNet.Tools.Run
foreach (var packageFolder in _context.LockFile.PackageFolders)
{
hostArgs.Insert(0, packageFolder.Path);
// DotNetHost doesn't handle additional probing paths with a trailing slash
hostArgs.Insert(0, PathUtility.EnsureNoTrailingSlash(packageFolder.Path));
hostArgs.Insert(0, probingPathArg);
}
}