Compile Microsoft.DotNet.Cli.Utils in net451
This commit is contained in:
parent
f5065c9425
commit
33f1b8551e
11 changed files with 59 additions and 50 deletions
|
@ -123,7 +123,11 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
|
||||
public ICommand EnvironmentVariable(string name, string value)
|
||||
{
|
||||
#if NET451
|
||||
_process.StartInfo.EnvironmentVariables[name] = value;
|
||||
#else
|
||||
_process.StartInfo.Environment[name] = value;
|
||||
#endif
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using NuGet.Frameworks;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using Microsoft.DotNet.ProjectModel.Graph;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using NuGet.Frameworks;
|
||||
using NuGet.Packaging;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Utils
|
||||
|
@ -32,7 +32,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
|
||||
private static CommandSpec ResolveFromAppBase(string commandName, IEnumerable<string> args, bool useComSpec = false)
|
||||
{
|
||||
var commandPath = Env.GetCommandPathFromAppBase(AppContext.BaseDirectory, commandName);
|
||||
var commandPath = Env.GetCommandPathFromAppBase(PlatformServices.Default.Application.ApplicationBasePath, commandName);
|
||||
return commandPath == null
|
||||
? null
|
||||
: CreateCommandSpecPreferringExe(commandName, args, commandPath, CommandResolutionStrategy.BaseDirectory, useComSpec);
|
||||
|
@ -210,7 +210,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
CommandResolutionStrategy resolutionStrategy,
|
||||
bool useComSpec = false)
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
|
||||
if (PlatformServices.Default.Runtime.OperatingSystemPlatform == Platform.Windows &&
|
||||
Path.GetExtension(commandPath).Equals(".cmd", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var preferredCommandPath = Env.GetCommandPath(commandName, ".exe");
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Utils
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
private static Platform CurrentPlatform => PlatformServices.Default.Runtime.OperatingSystemPlatform;
|
||||
|
||||
public static readonly string ProjectFileName = "project.json";
|
||||
public static readonly string ExeSuffix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : string.Empty;
|
||||
public static readonly string ExeSuffix = CurrentPlatform == Platform.Windows ? ".exe" : string.Empty;
|
||||
|
||||
// Priority order of runnable suffixes to look for and run
|
||||
public static readonly string[] RunnableSuffixes = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|
||||
public static readonly string[] RunnableSuffixes = CurrentPlatform == Platform.Windows
|
||||
? new string[] { ".exe", ".cmd", ".bat" }
|
||||
: new string[] { string.Empty };
|
||||
|
||||
|
@ -19,22 +21,23 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
public static readonly string BinDirectoryName = "bin";
|
||||
public static readonly string ObjDirectoryName = "obj";
|
||||
|
||||
public static readonly string DynamicLibSuffix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".dll" :
|
||||
RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? ".dylib" : ".so";
|
||||
public static readonly string DynamicLibSuffix = CurrentPlatform == Platform.Windows ? ".dll" :
|
||||
CurrentPlatform == Platform.Darwin ? ".dylib" : ".so";
|
||||
|
||||
public static readonly string LibCoreClrName = (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "coreclr" : "libcoreclr") + DynamicLibSuffix;
|
||||
public static readonly string LibCoreClrName = (CurrentPlatform == Platform.Windows ? "coreclr" : "libcoreclr") + DynamicLibSuffix;
|
||||
|
||||
public static readonly string RuntimeIdentifier = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "win7-x64" :
|
||||
RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "osx.10.10-x64" : "ubuntu.14.04-x64";
|
||||
public static readonly string RuntimeIdentifier = CurrentPlatform == Platform.Windows ? "win7-x64" :
|
||||
CurrentPlatform == Platform.Darwin ? "osx.10.10-x64" : "ubuntu.14.04-x64";
|
||||
|
||||
public static readonly string StaticLibSuffix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".lib" : ".a" ;
|
||||
public static readonly string StaticLibSuffix = CurrentPlatform == Platform.Windows ? ".lib" : ".a";
|
||||
|
||||
public static readonly string ResponseFileSuffix = ".rsp";
|
||||
|
||||
public static readonly string HostExecutableName = "corehost" + ExeSuffix;
|
||||
public static readonly string[] HostBinaryNames = new string[] {
|
||||
HostExecutableName,
|
||||
(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "hostpolicy" : "libhostpolicy") + DynamicLibSuffix
|
||||
(CurrentPlatform == Platform.Windows ? "hostpolicy" : "libhostpolicy") + DynamicLibSuffix
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Utils
|
||||
{
|
||||
|
@ -12,7 +11,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
/// <summary>
|
||||
/// Gets the path to the version of corehost that was shipped with this command
|
||||
/// </summary>
|
||||
public static string LocalHostExePath => Path.Combine(AppContext.BaseDirectory, Constants.HostExecutableName);
|
||||
public static string LocalHostExePath => Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, Constants.HostExecutableName);
|
||||
|
||||
public static string HostExePath
|
||||
{
|
||||
|
@ -33,7 +32,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
if (_hostDir == null)
|
||||
{
|
||||
_hostDir = Path.GetDirectoryName(Env.GetCommandPath(
|
||||
Constants.HostExecutableName, new[] {string.Empty}));
|
||||
Constants.HostExecutableName, new[] { string.Empty }));
|
||||
}
|
||||
|
||||
return _hostDir;
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Utils
|
||||
{
|
||||
|
@ -18,7 +19,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
if (_executableExtensions == null)
|
||||
{
|
||||
|
||||
_executableExtensions = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|
||||
_executableExtensions = PlatformServices.Default.Runtime.OperatingSystemPlatform == Platform.Windows
|
||||
? Environment.GetEnvironmentVariable("PATHEXT")
|
||||
.Split(';')
|
||||
.Select(e => e.ToLower().Trim('"'))
|
||||
|
@ -35,7 +36,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
{
|
||||
if (_searchPaths == null)
|
||||
{
|
||||
var searchPaths = new List<string> {AppContext.BaseDirectory};
|
||||
var searchPaths = new List<string> { PlatformServices.Default.Application.ApplicationBasePath };
|
||||
|
||||
searchPaths.AddRange(Environment
|
||||
.GetEnvironmentVariable("PATH")
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Common
|
||||
{
|
||||
|
@ -98,7 +98,7 @@ namespace Microsoft.DotNet.Tools.Common
|
|||
}
|
||||
|
||||
StringComparison compare;
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
if (PlatformServices.Default.Runtime.OperatingSystemPlatform == Platform.Windows)
|
||||
{
|
||||
compare = StringComparison.OrdinalIgnoreCase;
|
||||
// check if paths are on the same volume
|
||||
|
@ -154,7 +154,7 @@ namespace Microsoft.DotNet.Tools.Common
|
|||
path += ".." + separator;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (var i = index; len2 - 1 > i; ++i)
|
||||
{
|
||||
path += path2Segments[i] + separator;
|
||||
|
@ -216,7 +216,7 @@ namespace Microsoft.DotNet.Tools.Common
|
|||
{
|
||||
var comparison = StringComparison.Ordinal;
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
if (PlatformServices.Default.Runtime.OperatingSystemPlatform == Platform.Windows)
|
||||
{
|
||||
comparison = StringComparison.OrdinalIgnoreCase;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Utils
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
|
||||
public static Reporter Create(Func<bool, AnsiConsole> getter)
|
||||
{
|
||||
return new Reporter(getter(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)));
|
||||
return new Reporter(getter(PlatformServices.Default.Runtime.OperatingSystemPlatform == Platform.Windows));
|
||||
}
|
||||
|
||||
public void WriteLine(string message)
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.Cli.Utils.CommandParsing;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Utils
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
|
||||
var useComSpec = false;
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
if (PlatformServices.Default.Runtime.OperatingSystemPlatform == Platform.Windows)
|
||||
{
|
||||
// Only forward slashes are used in script blocks. Replace with backslashes to correctly
|
||||
// locate the script. The directory separator is platform-specific.
|
||||
|
@ -47,7 +47,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
var comSpec = Environment.GetEnvironmentVariable("ComSpec");
|
||||
if (!string.IsNullOrEmpty(comSpec))
|
||||
{
|
||||
useComSpec=true;
|
||||
useComSpec = true;
|
||||
|
||||
scriptArguments = new string[] { comSpec }
|
||||
.Concat(scriptArguments)
|
||||
|
|
|
@ -13,7 +13,6 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
|
||||
private StringBuilder _builder;
|
||||
private StringWriter _capture;
|
||||
private Action<string> _write;
|
||||
private Action<string> _writeLine;
|
||||
|
||||
public string CapturedOutput
|
||||
|
|
|
@ -2,20 +2,24 @@
|
|||
"version": "1.0.0-*",
|
||||
|
||||
"compilationOptions": {
|
||||
"keyFile": "../../tools/Key.snk"
|
||||
"keyFile": "../../tools/Key.snk",
|
||||
"warningsAsErrors": true
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23811",
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||
"System.Reflection.Metadata": "1.2.0-rc2-23811",
|
||||
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-16537"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"net451": { },
|
||||
"dnxcore50": {
|
||||
"imports": "portable-net45+win8"
|
||||
"imports": "portable-net45+win8",
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23811"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"scripts": {
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
{
|
||||
"description": "Abstractions for test runners to communicate to a tool, such as Visual Studio.",
|
||||
"version": "1.0.0-*",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/dotnet/cli"
|
||||
},
|
||||
"compilationOptions": {
|
||||
"warningsAsErrors": true,
|
||||
"keyFile": "../../tools/Key.snk"
|
||||
},
|
||||
"dependencies": {
|
||||
"Newtonsoft.Json": "7.0.1",
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||
"description": "Abstractions for test runners to communicate to a tool, such as Visual Studio.",
|
||||
"version": "1.0.0-*",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/dotnet/cli"
|
||||
},
|
||||
"compilationOptions": {
|
||||
"warningsAsErrors": true,
|
||||
"keyFile": "../../tools/Key.snk"
|
||||
},
|
||||
"dependencies": {
|
||||
"Newtonsoft.Json": "7.0.1",
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||
"Microsoft.Extensions.Logging.Abstractions": "1.0.0-rc2-16040"
|
||||
},
|
||||
"frameworks": {
|
||||
|
@ -22,9 +22,8 @@
|
|||
"NETStandard.Library": "1.0.0-rc2-23811",
|
||||
"System.Resources.ResourceManager": "4.0.1-rc2-23811",
|
||||
"System.Runtime.Serialization.Primitives": "4.1.0-rc2-23811"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
}
|
||||
}
|
||||
},
|
||||
"scripts": { }
|
||||
}
|
Loading…
Add table
Reference in a new issue