PR feedback.

This commit is contained in:
Eric Erhardt 2016-08-01 19:06:46 -05:00
parent 10cfa744e5
commit b5d312e7fa
6 changed files with 25 additions and 35 deletions

View file

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

View file

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

View file

@ -31,10 +31,10 @@ namespace Microsoft.DotNet.Core.Build.Tasks
IEnumerable<LockFileTargetLibrary> runtimeExports = lockFileTarget.Libraries;
// TODO: get this from the lock file once https://github.com/NuGet/Home/issues/2695 is fixed.
var packageName = "Microsoft.NETCore.App";
var platformPackageName = "Microsoft.NETCore.App";
var platformExport = lockFileTarget
.Libraries
.FirstOrDefault(e => e.Name.Equals(packageName, StringComparison.OrdinalIgnoreCase));
.FirstOrDefault(e => e.Name.Equals(platformPackageName, StringComparison.OrdinalIgnoreCase));
bool portable = platformExport != null;
if (portable)
@ -107,20 +107,20 @@ namespace Microsoft.DotNet.Core.Build.Tasks
var builder = new StringBuilder();
var packages = runtimeExports
.Where(libraryExport => libraryExport.Type == "package");
var seperator = "|";
var separator = "|";
foreach (var libraryExport in packages)
{
builder.Append(libraryExport.Name);
builder.Append(seperator);
builder.Append(separator);
builder.Append(libraryExport.Version.ToString());
builder.Append(seperator);
builder.Append(separator);
}
var hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(builder.ToString()));
builder.Clear();
foreach (var b in hash)
foreach (var hashByte in hash)
{
builder.AppendFormat("{0:x2}", b);
builder.AppendFormat("{0:x2}", hashByte);
}
return builder.ToString();
}

View file

@ -20,18 +20,15 @@ namespace Microsoft.DotNet.Core.Build.Tasks
/// </summary>
public class GenerateRuntimeConfigurationFiles : Task
{
[Required]
public string RuntimeOutputPath { get; set; }
[Required]
public string AssemblyName { get; set; }
[Required]
public string LockFilePath { get; set; }
public string RawRuntimeOptions { get; set; }
[Required]
public string RuntimeConfigPath { get; set; }
public bool IncludeDevConfig { get; set; }
public string RuntimeConfigDevPath { get; set; }
public string RawRuntimeOptions { get; set; }
private LockFile LockFile { get; set; }
@ -41,7 +38,7 @@ namespace Microsoft.DotNet.Core.Build.Tasks
WriteRuntimeConfig();
if (IncludeDevConfig)
if (!string.IsNullOrEmpty(RuntimeConfigDevPath))
{
WriteDevRuntimeConfig();
}
@ -57,10 +54,7 @@ namespace Microsoft.DotNet.Core.Build.Tasks
AddFramework(config.RuntimeOptions);
AddRuntimeOptions(config.RuntimeOptions);
var runtimeConfigJsonFile =
Path.Combine(RuntimeOutputPath, AssemblyName + ".runtimeconfig.json");
WriteToJsonFile(runtimeConfigJsonFile, config);
WriteToJsonFile(RuntimeConfigPath, config);
}
private void AddFramework(RuntimeOptions runtimeOptions)
@ -103,10 +97,7 @@ namespace Microsoft.DotNet.Core.Build.Tasks
AddAdditionalProbingPaths(devConfig.RuntimeOptions);
var runtimeConfigDevJsonFile =
Path.Combine(RuntimeOutputPath, AssemblyName + ".runtimeconfig.dev.json");
WriteToJsonFile(runtimeConfigDevJsonFile, devConfig);
WriteToJsonFile(RuntimeConfigDevPath, devConfig);
}
private void AddAdditionalProbingPaths(RuntimeOptions runtimeOptions)
@ -119,16 +110,16 @@ namespace Microsoft.DotNet.Core.Build.Tasks
}
// DotNetHost doesn't handle additional probing paths with a trailing slash
runtimeOptions.AdditionalProbingPaths.Add(EnsureNoTrailingSlash(packageFolder.Path));
runtimeOptions.AdditionalProbingPaths.Add(EnsureNoTrailingDirectorySeparator(packageFolder.Path));
}
}
private static string EnsureNoTrailingSlash(string path)
private static string EnsureNoTrailingDirectorySeparator(string path)
{
if (!string.IsNullOrEmpty(path))
{
char lastChar = path[path.Length - 1];
if (lastChar == Path.DirectorySeparatorChar || lastChar == '/')
if (lastChar == Path.DirectorySeparatorChar)
{
path = path.Substring(0, path.Length - 1);
}

View file

@ -67,10 +67,9 @@
TODO: Get RawRuntimeOptions from where it lives in the MSBuild world
-->
<GenerateRuntimeConfigurationFiles LockFilePath="$(MSBuildProjectDirectory)/project.lock.json"
RuntimeOutputPath="$(TargetDir)"
AssemblyName="$(AssemblyName)"
RawRuntimeOptions=""
IncludeDevConfig="true" />
RuntimeConfigPath="$(TargetDir)/$(AssemblyName).runtimeconfig.json"
RuntimeConfigDevPath="$(TargetDir)/$(AssemblyName).runtimeconfig.dev.json"
RawRuntimeOptions="" />
</Target>

View file

@ -154,7 +154,7 @@ namespace Microsoft.DotNet.Tools.Run
foreach (var packageFolder in _context.LockFile.PackageFolders)
{
// DotNetHost doesn't handle additional probing paths with a trailing slash
hostArgs.Insert(0, PathUtility.EnsureNoTrailingSlash(packageFolder.Path));
hostArgs.Insert(0, PathUtility.EnsureNoTrailingDirectorySeparator(packageFolder.Path));
hostArgs.Insert(0, probingPathArg);
}
}