PR feedback.
This commit is contained in:
parent
10cfa744e5
commit
b5d312e7fa
6 changed files with 25 additions and 35 deletions
|
@ -56,12 +56,12 @@ namespace Microsoft.DotNet.Tools.Common
|
||||||
return path + trailingCharacter;
|
return path + trailingCharacter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string EnsureNoTrailingSlash(string path)
|
public static string EnsureNoTrailingDirectorySeparator(string path)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(path))
|
if (!string.IsNullOrEmpty(path))
|
||||||
{
|
{
|
||||||
char lastChar = path[path.Length - 1];
|
char lastChar = path[path.Length - 1];
|
||||||
if (lastChar == Path.DirectorySeparatorChar || lastChar == '/')
|
if (lastChar == Path.DirectorySeparatorChar)
|
||||||
{
|
{
|
||||||
path = path.Substring(0, path.Length - 1);
|
path = path.Substring(0, path.Length - 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,7 +281,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
||||||
foreach (var packageFolder in _context.LockFile.PackageFolders)
|
foreach (var packageFolder in _context.LockFile.PackageFolders)
|
||||||
{
|
{
|
||||||
// DotNetHost doesn't handle additional probing paths with a trailing slash
|
// 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);
|
runtimeOptions.Add("additionalProbingPaths", additionalProbingPaths);
|
||||||
|
|
|
@ -31,10 +31,10 @@ namespace Microsoft.DotNet.Core.Build.Tasks
|
||||||
IEnumerable<LockFileTargetLibrary> runtimeExports = lockFileTarget.Libraries;
|
IEnumerable<LockFileTargetLibrary> runtimeExports = lockFileTarget.Libraries;
|
||||||
|
|
||||||
// TODO: get this from the lock file once https://github.com/NuGet/Home/issues/2695 is fixed.
|
// 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
|
var platformExport = lockFileTarget
|
||||||
.Libraries
|
.Libraries
|
||||||
.FirstOrDefault(e => e.Name.Equals(packageName, StringComparison.OrdinalIgnoreCase));
|
.FirstOrDefault(e => e.Name.Equals(platformPackageName, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
bool portable = platformExport != null;
|
bool portable = platformExport != null;
|
||||||
if (portable)
|
if (portable)
|
||||||
|
@ -107,20 +107,20 @@ namespace Microsoft.DotNet.Core.Build.Tasks
|
||||||
var builder = new StringBuilder();
|
var builder = new StringBuilder();
|
||||||
var packages = runtimeExports
|
var packages = runtimeExports
|
||||||
.Where(libraryExport => libraryExport.Type == "package");
|
.Where(libraryExport => libraryExport.Type == "package");
|
||||||
var seperator = "|";
|
var separator = "|";
|
||||||
foreach (var libraryExport in packages)
|
foreach (var libraryExport in packages)
|
||||||
{
|
{
|
||||||
builder.Append(libraryExport.Name);
|
builder.Append(libraryExport.Name);
|
||||||
builder.Append(seperator);
|
builder.Append(separator);
|
||||||
builder.Append(libraryExport.Version.ToString());
|
builder.Append(libraryExport.Version.ToString());
|
||||||
builder.Append(seperator);
|
builder.Append(separator);
|
||||||
}
|
}
|
||||||
var hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(builder.ToString()));
|
var hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(builder.ToString()));
|
||||||
|
|
||||||
builder.Clear();
|
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();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,18 +20,15 @@ namespace Microsoft.DotNet.Core.Build.Tasks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GenerateRuntimeConfigurationFiles : Task
|
public class GenerateRuntimeConfigurationFiles : Task
|
||||||
{
|
{
|
||||||
[Required]
|
|
||||||
public string RuntimeOutputPath { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public string AssemblyName { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string LockFilePath { get; set; }
|
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; }
|
private LockFile LockFile { get; set; }
|
||||||
|
|
||||||
|
@ -41,7 +38,7 @@ namespace Microsoft.DotNet.Core.Build.Tasks
|
||||||
|
|
||||||
WriteRuntimeConfig();
|
WriteRuntimeConfig();
|
||||||
|
|
||||||
if (IncludeDevConfig)
|
if (!string.IsNullOrEmpty(RuntimeConfigDevPath))
|
||||||
{
|
{
|
||||||
WriteDevRuntimeConfig();
|
WriteDevRuntimeConfig();
|
||||||
}
|
}
|
||||||
|
@ -57,10 +54,7 @@ namespace Microsoft.DotNet.Core.Build.Tasks
|
||||||
AddFramework(config.RuntimeOptions);
|
AddFramework(config.RuntimeOptions);
|
||||||
AddRuntimeOptions(config.RuntimeOptions);
|
AddRuntimeOptions(config.RuntimeOptions);
|
||||||
|
|
||||||
var runtimeConfigJsonFile =
|
WriteToJsonFile(RuntimeConfigPath, config);
|
||||||
Path.Combine(RuntimeOutputPath, AssemblyName + ".runtimeconfig.json");
|
|
||||||
|
|
||||||
WriteToJsonFile(runtimeConfigJsonFile, config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddFramework(RuntimeOptions runtimeOptions)
|
private void AddFramework(RuntimeOptions runtimeOptions)
|
||||||
|
@ -103,10 +97,7 @@ namespace Microsoft.DotNet.Core.Build.Tasks
|
||||||
|
|
||||||
AddAdditionalProbingPaths(devConfig.RuntimeOptions);
|
AddAdditionalProbingPaths(devConfig.RuntimeOptions);
|
||||||
|
|
||||||
var runtimeConfigDevJsonFile =
|
WriteToJsonFile(RuntimeConfigDevPath, devConfig);
|
||||||
Path.Combine(RuntimeOutputPath, AssemblyName + ".runtimeconfig.dev.json");
|
|
||||||
|
|
||||||
WriteToJsonFile(runtimeConfigDevJsonFile, devConfig);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddAdditionalProbingPaths(RuntimeOptions runtimeOptions)
|
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
|
// 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))
|
if (!string.IsNullOrEmpty(path))
|
||||||
{
|
{
|
||||||
char lastChar = path[path.Length - 1];
|
char lastChar = path[path.Length - 1];
|
||||||
if (lastChar == Path.DirectorySeparatorChar || lastChar == '/')
|
if (lastChar == Path.DirectorySeparatorChar)
|
||||||
{
|
{
|
||||||
path = path.Substring(0, path.Length - 1);
|
path = path.Substring(0, path.Length - 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,10 +67,9 @@
|
||||||
TODO: Get RawRuntimeOptions from where it lives in the MSBuild world
|
TODO: Get RawRuntimeOptions from where it lives in the MSBuild world
|
||||||
-->
|
-->
|
||||||
<GenerateRuntimeConfigurationFiles LockFilePath="$(MSBuildProjectDirectory)/project.lock.json"
|
<GenerateRuntimeConfigurationFiles LockFilePath="$(MSBuildProjectDirectory)/project.lock.json"
|
||||||
RuntimeOutputPath="$(TargetDir)"
|
RuntimeConfigPath="$(TargetDir)/$(AssemblyName).runtimeconfig.json"
|
||||||
AssemblyName="$(AssemblyName)"
|
RuntimeConfigDevPath="$(TargetDir)/$(AssemblyName).runtimeconfig.dev.json"
|
||||||
RawRuntimeOptions=""
|
RawRuntimeOptions="" />
|
||||||
IncludeDevConfig="true" />
|
|
||||||
|
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ namespace Microsoft.DotNet.Tools.Run
|
||||||
foreach (var packageFolder in _context.LockFile.PackageFolders)
|
foreach (var packageFolder in _context.LockFile.PackageFolders)
|
||||||
{
|
{
|
||||||
// DotNetHost doesn't handle additional probing paths with a trailing slash
|
// 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);
|
hostArgs.Insert(0, probingPathArg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue