From b5d312e7faff0e551b58e493bbb1d0de48999954 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Mon, 1 Aug 2016 19:06:46 -0500 Subject: [PATCH] PR feedback. --- src/Microsoft.DotNet.Cli.Utils/PathUtility.cs | 4 +-- .../Executable.cs | 2 +- .../DependencyContextBuilder.cs | 14 ++++----- .../GenerateRuntimeConfigurationFiles.cs | 31 +++++++------------ src/dotnet/Microsoft.DotNet.Core.Sdk.targets | 7 ++--- src/dotnet/commands/dotnet-run/RunCommand.cs | 2 +- 6 files changed, 25 insertions(+), 35 deletions(-) diff --git a/src/Microsoft.DotNet.Cli.Utils/PathUtility.cs b/src/Microsoft.DotNet.Cli.Utils/PathUtility.cs index e9fdcb99c..abcea770b 100644 --- a/src/Microsoft.DotNet.Cli.Utils/PathUtility.cs +++ b/src/Microsoft.DotNet.Cli.Utils/PathUtility.cs @@ -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); } diff --git a/src/Microsoft.DotNet.Compiler.Common/Executable.cs b/src/Microsoft.DotNet.Compiler.Common/Executable.cs index 4427c7ecc..a3ee3544b 100644 --- a/src/Microsoft.DotNet.Compiler.Common/Executable.cs +++ b/src/Microsoft.DotNet.Compiler.Common/Executable.cs @@ -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); diff --git a/src/Microsoft.DotNet.Core.Build.Tasks/DependencyContextBuilder.cs b/src/Microsoft.DotNet.Core.Build.Tasks/DependencyContextBuilder.cs index d7a7189cc..757a2c08a 100644 --- a/src/Microsoft.DotNet.Core.Build.Tasks/DependencyContextBuilder.cs +++ b/src/Microsoft.DotNet.Core.Build.Tasks/DependencyContextBuilder.cs @@ -31,10 +31,10 @@ namespace Microsoft.DotNet.Core.Build.Tasks IEnumerable 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(); } diff --git a/src/Microsoft.DotNet.Core.Build.Tasks/GenerateRuntimeConfigurationFiles.cs b/src/Microsoft.DotNet.Core.Build.Tasks/GenerateRuntimeConfigurationFiles.cs index 6d973f512..d32327b74 100644 --- a/src/Microsoft.DotNet.Core.Build.Tasks/GenerateRuntimeConfigurationFiles.cs +++ b/src/Microsoft.DotNet.Core.Build.Tasks/GenerateRuntimeConfigurationFiles.cs @@ -20,18 +20,15 @@ namespace Microsoft.DotNet.Core.Build.Tasks /// 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); } diff --git a/src/dotnet/Microsoft.DotNet.Core.Sdk.targets b/src/dotnet/Microsoft.DotNet.Core.Sdk.targets index 35f0961d5..0faa0d006 100644 --- a/src/dotnet/Microsoft.DotNet.Core.Sdk.targets +++ b/src/dotnet/Microsoft.DotNet.Core.Sdk.targets @@ -67,10 +67,9 @@ TODO: Get RawRuntimeOptions from where it lives in the MSBuild world --> + RuntimeConfigPath="$(TargetDir)/$(AssemblyName).runtimeconfig.json" + RuntimeConfigDevPath="$(TargetDir)/$(AssemblyName).runtimeconfig.dev.json" + RawRuntimeOptions="" /> diff --git a/src/dotnet/commands/dotnet-run/RunCommand.cs b/src/dotnet/commands/dotnet-run/RunCommand.cs index 618f8074f..5653f98fb 100644 --- a/src/dotnet/commands/dotnet-run/RunCommand.cs +++ b/src/dotnet/commands/dotnet-run/RunCommand.cs @@ -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); } }