add proper RID detection based on PlatformAbstractions
This commit is contained in:
parent
2d4fe4bc10
commit
f4df12f2e2
25 changed files with 293 additions and 175 deletions
|
@ -70,6 +70,7 @@ EndProject
|
|||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Extensions.DependencyModel", "src\Microsoft.Extensions.DependencyModel\Microsoft.Extensions.DependencyModel.xproj", "{688870C8-9843-4F9E-8576-D39290AD0F25}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Tools.Compiler.Fsc", "src\Microsoft.DotNet.Tools.Compiler.Fsc\Microsoft.DotNet.Tools.Compiler.Fsc.xproj", "{74F25188-BF63-4BF3-879B-B6CDB11ED608}"
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "E2E", "test\E2E\E2E.xproj", "{65741CB1-8AEE-4C66-8198-10A7EA0E4258}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -547,6 +548,22 @@ Global
|
|||
{11C77123-E4DA-499F-8900-80C88C2C69F2}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
|
||||
{11C77123-E4DA-499F-8900-80C88C2C69F2}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
|
||||
{11C77123-E4DA-499F-8900-80C88C2C69F2}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
|
||||
{65741CB1-8AEE-4C66-8198-10A7EA0E4258}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{65741CB1-8AEE-4C66-8198-10A7EA0E4258}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{65741CB1-8AEE-4C66-8198-10A7EA0E4258}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{65741CB1-8AEE-4C66-8198-10A7EA0E4258}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{65741CB1-8AEE-4C66-8198-10A7EA0E4258}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{65741CB1-8AEE-4C66-8198-10A7EA0E4258}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
|
||||
{65741CB1-8AEE-4C66-8198-10A7EA0E4258}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
|
||||
{65741CB1-8AEE-4C66-8198-10A7EA0E4258}.MinSizeRel|x64.Build.0 = Debug|Any CPU
|
||||
{65741CB1-8AEE-4C66-8198-10A7EA0E4258}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{65741CB1-8AEE-4C66-8198-10A7EA0E4258}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{65741CB1-8AEE-4C66-8198-10A7EA0E4258}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{65741CB1-8AEE-4C66-8198-10A7EA0E4258}.Release|x64.Build.0 = Release|Any CPU
|
||||
{65741CB1-8AEE-4C66-8198-10A7EA0E4258}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{65741CB1-8AEE-4C66-8198-10A7EA0E4258}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
|
||||
{65741CB1-8AEE-4C66-8198-10A7EA0E4258}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
|
||||
{65741CB1-8AEE-4C66-8198-10A7EA0E4258}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -581,5 +598,6 @@ Global
|
|||
{79620410-4EC7-4A38-A8C3-EE81243F818E} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
|
||||
{1EA9AF94-5494-40DD-A05B-9D564572CCFC} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
|
||||
{11C77123-E4DA-499F-8900-80C88C2C69F2} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
|
||||
{65741CB1-8AEE-4C66-8198-10A7EA0E4258} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -33,6 +33,10 @@ else {
|
|||
header "Compiling"
|
||||
_ "$RepoRoot\scripts\compile\compile.ps1" @("$Configuration")
|
||||
|
||||
# Put stage2 on the PATH now that we have a build
|
||||
$env:PATH = "$Stage2Dir\bin;$env:PATH"
|
||||
$env:DOTNET_HOME = "$Stage2Dir"
|
||||
|
||||
header "Running Tests"
|
||||
_ "$RepoRoot\scripts\test\runtests.ps1"
|
||||
|
||||
|
@ -46,4 +50,4 @@ header "Generating dotnet MSI"
|
|||
_ "$RepoRoot\packaging\windows\generatemsi.ps1" @("$Stage2Dir")
|
||||
|
||||
header "Generating NuGet packages"
|
||||
_ "$RepoRoot\packaging\nuget\package.ps1" @("$Stage2Dir\bin", "$VersionSuffix")
|
||||
_ "$RepoRoot\packaging\nuget\package.ps1" @("$Stage2Dir\bin", "$VersionSuffix")
|
||||
|
|
|
@ -37,7 +37,10 @@ fi
|
|||
header "Compiling"
|
||||
$REPOROOT/scripts/compile/compile.sh
|
||||
|
||||
# Run tests on the stage2 output
|
||||
# Put stage2 on the PATH now that we have a build
|
||||
export DOTNET_TOOLS=$STAGE1_DIR
|
||||
export PATH=$STAGE2_DIR/bin:$PATH
|
||||
|
||||
header "Testing stage2..."
|
||||
DOTNET_HOME=$STAGE2_DIR DOTNET_TOOLS=$STAGE2_DIR $REPOROOT/scripts/test/runtests.sh
|
||||
|
||||
|
@ -52,4 +55,4 @@ if [ ! -z "$NOPACKAGE" ]; then
|
|||
$REPOROOT/scripts/package/package-native.sh
|
||||
else
|
||||
header "Skipping packaging"
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -17,9 +17,11 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
|||
source "$DIR/../common/_common.sh"
|
||||
|
||||
header "Restoring packages"
|
||||
$DNX_ROOT/dnu restore "$REPOROOT/src" --quiet --runtime "$RID" "$NOCACHE" --parallel
|
||||
$DNX_ROOT/dnu restore "$REPOROOT/test" --quiet --runtime "$RID" "$NOCACHE" --parallel
|
||||
$DNX_ROOT/dnu restore "$REPOROOT/tools" --quiet --runtime "$RID" "$NOCACHE" --parallel
|
||||
|
||||
#Temporarily restore for ALL THE RIDS! This solves a bootstrapping problem in this fix
|
||||
$DNX_ROOT/dnu restore "$REPOROOT/src" --quiet --runtime win7-x64 --runtime ubuntu.14.04-x64 --runtime osx.10.10-x64 --runtime osx.10.11-x64 --runtime centos.7.1-x64 "$NOCACHE" --parallel
|
||||
$DNX_ROOT/dnu restore "$REPOROOT/test" --quiet --runtime win7-x64 --runtime ubuntu.14.04-x64 --runtime osx.10.10-x64 --runtime osx.10.11-x64 --runtime centos.7.1-x64 "$NOCACHE" --parallel
|
||||
$DNX_ROOT/dnu restore "$REPOROOT/tools" --quiet --runtime win7-x64 --runtime ubuntu.14.04-x64 --runtime osx.10.10-x64 --runtime osx.10.11-x64 --runtime centos.7.1-x64 "$NOCACHE" --parallel
|
||||
set +e
|
||||
$DNX_ROOT/dnu restore "$REPOROOT/testapp" --quiet --runtime "$RID" "$NOCACHE" --parallel >/dev/null 2>&1
|
||||
$DNX_ROOT/dnu restore "$REPOROOT/testapp" --quiet --runtime win7-x64 --runtime ubuntu.14.04-x64 --runtime osx.10.10-x64 --runtime osx.10.11-x64 --runtime centos.7.1-x64 "$NOCACHE" --parallel >/dev/null 2>&1
|
||||
set -e
|
||||
|
|
|
@ -12,7 +12,7 @@ if [ -z "$RID" ]; then
|
|||
if [ -n "$(sw_vers -productVersion | grep 10.10)" ]; then
|
||||
export RID=osx.10.10-x64
|
||||
elif [ -n "$(sw_vers -productVersion | grep 10.11)" ]; then
|
||||
export RID=osx.10.10-x64
|
||||
export RID=osx.10.11-x64
|
||||
else
|
||||
error "unknown OS X: $(sw_vers -productVersion)" 1>&2
|
||||
fi
|
||||
|
@ -34,4 +34,4 @@ fi
|
|||
|
||||
if [ -z "$RID" ]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -10,15 +10,14 @@ BIN_DIR="$( cd $1 && pwd )"
|
|||
|
||||
UNAME=`uname`
|
||||
|
||||
if [ -z "$RID" ]; then
|
||||
if [ "$UNAME" == "Darwin" ]; then
|
||||
RID=osx.10.10-x64
|
||||
elif [ "$UNAME" == "Linux" ]; then
|
||||
RID=ubuntu.14.04-x64
|
||||
else
|
||||
echo "Unknown OS: $UNAME" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
# Always recalculate the RID because the package always uses a specific RID, regardless of OS X version or Linux distro.
|
||||
if [ "$UNAME" == "Darwin" ]; then
|
||||
RID=osx.10.10-x64
|
||||
elif [ "$UNAME" == "Linux" ]; then
|
||||
RID=ubuntu.14.04-x64
|
||||
else
|
||||
echo "Unknown OS: $UNAME" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Replace with a robust method for finding the right crossgen.exe
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
. "$PSScriptRoot\..\common\_common.ps1"
|
||||
|
||||
$failCount = 0
|
||||
|
||||
$TestBinRoot = "$RepoRoot\artifacts\tests"
|
||||
|
||||
$TestProjects = @(
|
||||
|
@ -45,7 +47,7 @@ pushd "$TestBinRoot"
|
|||
|
||||
# Run each test project
|
||||
$TestProjects | ForEach-Object {
|
||||
& "corerun.exe" "xunit.console.netcore.exe" "$_.dll" -xml "$_-testResults.xml" -notrait category=failing
|
||||
& ".\corerun" "xunit.console.netcore.exe" "$_.dll" -xml "$_-testResults.xml" -notrait category=failing
|
||||
$exitCode = $LastExitCode
|
||||
if ($exitCode -ne 0) {
|
||||
$failingTests += "$_"
|
||||
|
@ -61,8 +63,7 @@ if ($failCount -ne 0) {
|
|||
$failingTests | ForEach-Object {
|
||||
Write-Host -ForegroundColor Red "$_.dll failed. Logs in '$TestBinRoot\$_-testResults.xml'"
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Write-Host -ForegroundColor Green "All the tests passed!"
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ TestProjects=( \
|
|||
Microsoft.DotNet.Tools.Publish.Tests \
|
||||
)
|
||||
|
||||
|
||||
for project in ${TestProjects[@]}
|
||||
do
|
||||
dotnet publish --framework "dnxcore50" --runtime "$RID" --output "$TestBinRoot" --configuration "$CONFIGURATION" "$REPOROOT/test/$project"
|
||||
|
@ -43,7 +42,7 @@ failCount=0
|
|||
|
||||
for project in ${TestProjects[@]}
|
||||
do
|
||||
./corerun "xunit.console.netcore.exe" "$project.dll" -xml "${project}-testResults.xml" -notrait category=failing
|
||||
./corerun "xunit.console.netcore.exe" "$project.dll" -xml "${project}-testResults.xml" -notrait category=failing
|
||||
exitCode=$?
|
||||
failCount+=$exitCode
|
||||
if [ $exitCode -ne 0 ]; then
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Extensions.PlatformAbstractions
|
||||
{
|
||||
// This is to support some legacy stuff.
|
||||
// dnu restore (and thus dotnet restore) always uses win7-x64 as the Windows restore target,
|
||||
// so, when picking targets out of the lock file, we need to do version fallback since the
|
||||
// active RID might be higher than the RID in the lock file.
|
||||
//
|
||||
// We should clean this up. Filed #619 to track.
|
||||
public static class RuntimeEnvironmentRidExtensions
|
||||
{
|
||||
// Gets the identfier that is used for restore by default (this is different from the actual RID, but only on Windows)
|
||||
public static string GetLegacyRestoreRuntimeIdentifier(this IRuntimeEnvironment env)
|
||||
{
|
||||
if (env.OperatingSystemPlatform != Platform.Windows)
|
||||
{
|
||||
return env.GetRuntimeIdentifier();
|
||||
}
|
||||
else
|
||||
{
|
||||
var arch = env.RuntimeArchitecture.ToLowerInvariant();
|
||||
return "win7-" + arch;
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<string> GetAllCandidateRuntimeIdentifiers(this IRuntimeEnvironment env)
|
||||
{
|
||||
if (env.OperatingSystemPlatform != Platform.Windows)
|
||||
{
|
||||
yield return env.GetRuntimeIdentifier();
|
||||
}
|
||||
else
|
||||
{
|
||||
var arch = env.RuntimeArchitecture.ToLowerInvariant();
|
||||
if (env.OperatingSystemVersion.StartsWith("6.1", StringComparison.Ordinal))
|
||||
{
|
||||
yield return "win7-" + arch;
|
||||
}
|
||||
else if (env.OperatingSystemVersion.StartsWith("6.2", StringComparison.Ordinal))
|
||||
{
|
||||
yield return "win8-" + arch;
|
||||
yield return "win7-" + arch;
|
||||
}
|
||||
else if (env.OperatingSystemVersion.StartsWith("6.3", StringComparison.Ordinal))
|
||||
{
|
||||
yield return "win81-" + arch;
|
||||
yield return "win8-" + arch;
|
||||
yield return "win7-" + arch;
|
||||
}
|
||||
else if (env.OperatingSystemVersion.StartsWith("10.0", StringComparison.Ordinal))
|
||||
{
|
||||
yield return "win10-" + arch;
|
||||
yield return "win81-" + arch;
|
||||
yield return "win8-" + arch;
|
||||
yield return "win7-" + arch;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,14 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23704",
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0",
|
||||
"System.Reflection.Metadata": "1.1.0"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"dnxcore50": { }
|
||||
}
|
||||
"version": "1.0.0-*",
|
||||
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23704",
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0",
|
||||
"System.Reflection.Metadata": "1.1.0",
|
||||
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-16530"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"dnxcore50": { }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,15 +4,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using NuGet.Frameworks;
|
||||
|
||||
namespace Microsoft.DotNet.Cli
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
private const string HelpText = @".NET Command Line Interface
|
||||
Usage: dotnet [common-options] [command] [arguments]
|
||||
private const string ProductLongName = ".NET Command Line Tools";
|
||||
private const string UsageText = @"Usage: dotnet [common-options] [command] [arguments]
|
||||
|
||||
Arguments:
|
||||
[command] The command to execute
|
||||
|
@ -20,6 +22,7 @@ Arguments:
|
|||
|
||||
Common Options (passed before the command):
|
||||
-v|--verbose Enable verbose output
|
||||
--version Display .NET CLI Version Info
|
||||
|
||||
Common Commands:
|
||||
new Initialize a basic .NET project
|
||||
|
@ -29,6 +32,13 @@ Common Commands:
|
|||
run Compiles and immediately executes a .NET project
|
||||
repl Launch an interactive session (read, eval, print, loop)
|
||||
pack Creates a NuGet package";
|
||||
private static readonly string ProductVersion = GetProductVersion();
|
||||
|
||||
private static string GetProductVersion()
|
||||
{
|
||||
var attr = typeof(Program).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
|
||||
return attr?.InformationalVersion;
|
||||
}
|
||||
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
|
@ -45,6 +55,11 @@ Common Commands:
|
|||
{
|
||||
verbose = true;
|
||||
}
|
||||
else if(IsArg(args[lastArg], "version"))
|
||||
{
|
||||
PrintVersionInfo();
|
||||
return 0;
|
||||
}
|
||||
else if (IsArg(args[lastArg], "h", "help"))
|
||||
{
|
||||
PrintHelp();
|
||||
|
@ -102,12 +117,38 @@ Common Commands:
|
|||
|
||||
private static void PrintHelp()
|
||||
{
|
||||
Reporter.Output.WriteLine(HelpText);
|
||||
PrintVersionHeader();
|
||||
Reporter.Output.WriteLine(UsageText);
|
||||
}
|
||||
|
||||
private static void PrintVersionHeader()
|
||||
{
|
||||
var versionString = string.IsNullOrEmpty(ProductVersion) ?
|
||||
string.Empty :
|
||||
$" ({ProductVersion})";
|
||||
Reporter.Output.WriteLine(ProductLongName + versionString);
|
||||
}
|
||||
|
||||
private static void PrintVersionInfo()
|
||||
{
|
||||
PrintVersionHeader();
|
||||
|
||||
var runtimeEnvironment = PlatformServices.Default.Runtime;
|
||||
Reporter.Output.WriteLine("Runtime Environment:");
|
||||
Reporter.Output.WriteLine($" OS Name: {runtimeEnvironment.OperatingSystem}");
|
||||
Reporter.Output.WriteLine($" OS Version: {runtimeEnvironment.OperatingSystemVersion}");
|
||||
Reporter.Output.WriteLine($" OS Platform: {runtimeEnvironment.OperatingSystemPlatform}");
|
||||
Reporter.Output.WriteLine($" Runtime Id: {runtimeEnvironment.GetRuntimeIdentifier()}");
|
||||
}
|
||||
|
||||
private static bool IsArg(string candidate, string longName)
|
||||
{
|
||||
return IsArg(candidate, shortName: null, longName: longName);
|
||||
}
|
||||
|
||||
private static bool IsArg(string candidate, string shortName, string longName)
|
||||
{
|
||||
return candidate.Equals("-" + shortName) || candidate.Equals("--" + longName);
|
||||
return (shortName != null && candidate.Equals("-" + shortName)) || (longName != null && candidate.Equals("--" + longName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
// 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;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel
|
||||
{
|
||||
public static class RuntimeIdentifier
|
||||
{
|
||||
public static string Current { get; } = DetermineRID();
|
||||
|
||||
private static string DetermineRID()
|
||||
{
|
||||
// TODO: Not this, obviously. Do proper RID detection
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
return "win7-x64";
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
if(IsCentOS())
|
||||
{
|
||||
return "centos.7-x64";
|
||||
}
|
||||
else if(IsUbuntu())
|
||||
{
|
||||
return "ubuntu.14.04-x64";
|
||||
}
|
||||
else
|
||||
{
|
||||
// unknown distro. Lets fail fast
|
||||
throw new InvalidOperationException("Current linux distro is not supported.");
|
||||
}
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
return "osx.10.10-x64";
|
||||
}
|
||||
|
||||
throw new InvalidOperationException("Current operating system is not supported.");
|
||||
}
|
||||
|
||||
private static bool IsCentOS()
|
||||
{
|
||||
return IsLinuxDistro("centos");
|
||||
}
|
||||
|
||||
private static bool IsUbuntu()
|
||||
{
|
||||
return IsLinuxDistro("ubuntu");
|
||||
}
|
||||
|
||||
private static bool IsLinuxDistro(string distro)
|
||||
{
|
||||
// HACK - A file which can be found in most linux distros
|
||||
// Did not test in non-en distros
|
||||
const string OSIDFILE = "/etc/os-release";
|
||||
|
||||
if(!File.Exists(OSIDFILE))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return File.ReadAllText(OSIDFILE).ToLower().Contains(distro);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,6 +13,7 @@ using Microsoft.DotNet.ProjectModel.Compilation;
|
|||
using Microsoft.DotNet.ProjectModel.Utilities;
|
||||
using NuGet.Frameworks;
|
||||
using Microsoft.Extensions.DependencyModel;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Compiler
|
||||
{
|
||||
|
@ -344,8 +345,9 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
|
||||
if (success && !args.NoHostValue && compilationOptions.EmitEntryPoint.GetValueOrDefault())
|
||||
{
|
||||
var projectContext = ProjectContext.Create(context.ProjectDirectory, context.TargetFramework, new[] { RuntimeIdentifier.Current });
|
||||
projectContext
|
||||
var rids = PlatformServices.Default.Runtime.GetAllCandidateRuntimeIdentifiers();
|
||||
var runtimeContext = ProjectContext.Create(context.ProjectDirectory, context.TargetFramework, rids);
|
||||
runtimeContext
|
||||
.MakeCompilationOutputRunnable(outputPath, args.ConfigValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,31 +1,33 @@
|
|||
{
|
||||
"name": "dotnet-compile",
|
||||
"version": "1.0.0-*",
|
||||
"compilationOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23704",
|
||||
"System.Reflection.Metadata": "1.1.0",
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||
"Microsoft.DotNet.Compiler.Common": "1.0.0-*",
|
||||
"Microsoft.DotNet.Cli.Utils": "1.0.0-*",
|
||||
"Microsoft.Extensions.CommandLineUtils.Sources": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
"name": "dotnet-compile",
|
||||
"version": "1.0.0-*",
|
||||
"compilationOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"Microsoft.Extensions.DependencyModel": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23704",
|
||||
"System.Reflection.Metadata": "1.1.0",
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||
"Microsoft.DotNet.Compiler.Common": "1.0.0-*",
|
||||
"Microsoft.DotNet.Cli.Utils": "1.0.0-*",
|
||||
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-*",
|
||||
|
||||
"Microsoft.Extensions.CommandLineUtils.Sources": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
},
|
||||
"Microsoft.Extensions.DependencyModel": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
}
|
||||
},
|
||||
"frameworks": {
|
||||
"dnxcore50": { }
|
||||
},
|
||||
"scripts": {
|
||||
"postcompile": [
|
||||
"../../scripts/build/place-binary \"%compile:OutputDir%/%project:Name%.dll\"",
|
||||
"../../scripts/build/place-binary \"%compile:OutputDir%/%project:Name%.pdb\""
|
||||
]
|
||||
}
|
||||
},
|
||||
"frameworks": {
|
||||
"dnxcore50": { }
|
||||
},
|
||||
"scripts": {
|
||||
"postcompile": [
|
||||
"../../scripts/build/place-binary \"%compile:OutputDir%/%project:Name%.dll\"",
|
||||
"../../scripts/build/place-binary \"%compile:OutputDir%/%project:Name%.pdb\""
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ using Microsoft.DotNet.Cli.Utils;
|
|||
using Microsoft.DotNet.ProjectModel;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Publish
|
||||
{
|
||||
|
@ -33,8 +34,7 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
var publish = new PublishCommand();
|
||||
|
||||
publish.Framework = framework.Value();
|
||||
// TODO: Remove default once xplat publish is enabled.
|
||||
publish.Runtime = runtime.Value() ?? RuntimeIdentifier.Current;
|
||||
publish.Runtime = runtime.Value();
|
||||
publish.OutputPath = output.Value();
|
||||
publish.Configuration = configuration.Value() ?? Constants.DefaultConfiguration;
|
||||
publish.NativeSubdirectories = nativeSubdirectories.HasValue();
|
||||
|
|
|
@ -9,6 +9,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Publish
|
||||
{
|
||||
|
@ -39,10 +40,8 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
}
|
||||
}
|
||||
|
||||
ProjectContexts = ProjectContext.CreateContextForEachTarget(ProjectPath);
|
||||
ProjectContexts = GetMatchingProjectContexts(ProjectContexts, NugetFramework, Runtime);
|
||||
|
||||
if (ProjectContexts.Count() == 0)
|
||||
ProjectContexts = SelectContexts(ProjectPath, NugetFramework, Runtime);
|
||||
if (!ProjectContexts.Any())
|
||||
{
|
||||
string errMsg = $"'{ProjectPath}' cannot be published for '{Framework ?? "<no framework provided>"}' '{Runtime ?? "<no runtime provided>"}'";
|
||||
Reporter.Output.WriteLine(errMsg.Red());
|
||||
|
@ -67,29 +66,6 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the matching framework/runtime ProjectContext.
|
||||
/// If 'nugetframework' or 'runtime' is null or empty then it matches with any.
|
||||
/// </summary>
|
||||
private static IEnumerable<ProjectContext> GetMatchingProjectContexts(IEnumerable<ProjectContext> contexts, NuGetFramework framework, string runtimeIdentifier)
|
||||
{
|
||||
foreach (var context in contexts)
|
||||
{
|
||||
if (context.TargetFramework == null || string.IsNullOrEmpty(context.RuntimeIdentifier))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(runtimeIdentifier) || runtimeIdentifier.Equals(context.RuntimeIdentifier))
|
||||
{
|
||||
if (framework == null || framework.Equals(context.TargetFramework))
|
||||
{
|
||||
yield return context;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Publish the project for given 'framework (ex - dnxcore50)' and 'runtimeID (ex - win7-x64)'
|
||||
/// </summary>
|
||||
|
@ -228,5 +204,51 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
|
||||
return candidate;
|
||||
}
|
||||
|
||||
private static IEnumerable<ProjectContext> SelectContexts(string projectPath, NuGetFramework framework, string runtime)
|
||||
{
|
||||
var allContexts = ProjectContext.CreateContextForEachTarget(projectPath);
|
||||
if (string.IsNullOrEmpty(runtime))
|
||||
{
|
||||
// Nothing was specified, so figure out what the candidate runtime identifiers are and try each of them
|
||||
// Temporary until #619 is resolved
|
||||
foreach (var candidate in PlatformServices.Default.Runtime.GetAllCandidateRuntimeIdentifiers())
|
||||
{
|
||||
var contexts = GetMatchingProjectContexts(allContexts, framework, candidate);
|
||||
if (contexts.Any())
|
||||
{
|
||||
return contexts;
|
||||
}
|
||||
}
|
||||
return Enumerable.Empty<ProjectContext>();
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetMatchingProjectContexts(allContexts, framework, runtime);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the matching framework/runtime ProjectContext.
|
||||
/// If 'framework' or 'runtimeIdentifier' is null or empty then it matches with any.
|
||||
/// </summary>
|
||||
private static IEnumerable<ProjectContext> GetMatchingProjectContexts(IEnumerable<ProjectContext> contexts, NuGetFramework framework, string runtimeIdentifier)
|
||||
{
|
||||
foreach (var context in contexts)
|
||||
{
|
||||
if (context.TargetFramework == null || string.IsNullOrEmpty(context.RuntimeIdentifier))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(runtimeIdentifier) || string.Equals(runtimeIdentifier, context.RuntimeIdentifier, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (framework == null || framework.Equals(context.TargetFramework))
|
||||
{
|
||||
yield return context;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,14 @@ using Microsoft.Dnx.Runtime.Common.CommandLine;
|
|||
using Microsoft.DotNet.ProjectModel;
|
||||
using Microsoft.DotNet.ProjectModel.Graph;
|
||||
using NuGet.Frameworks;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Restore
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
private static readonly string DefaultRid = PlatformServices.Default.Runtime.GetLegacyRestoreRuntimeIdentifier();
|
||||
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
DebugHelper.HandleDebugSwitch(ref args);
|
||||
|
@ -130,7 +133,7 @@ namespace Microsoft.DotNet.Tools.Restore
|
|||
private static void CreateDepsInPackageCache(LibraryRange toolLibrary, string projectPath)
|
||||
{
|
||||
var context = ProjectContext.Create(projectPath,
|
||||
FrameworkConstants.CommonFrameworks.DnxCore50, new[] { RuntimeIdentifier.Current });
|
||||
FrameworkConstants.CommonFrameworks.DnxCore50, new[] { DefaultRid });
|
||||
|
||||
var toolDescription = context.LibraryManager.GetLibraries()
|
||||
.Select(l => l as PackageDescription)
|
||||
|
@ -155,7 +158,7 @@ namespace Microsoft.DotNet.Tools.Restore
|
|||
var projectPath = Path.Combine(tempPath, Project.FileName);
|
||||
File.WriteAllText(projectPath, GenerateProjectJsonContents(new[] {"dnxcore50"}));
|
||||
Dnx.RunPackageInstall(tooldep, projectPath, args);
|
||||
Dnx.RunRestore(new [] { $"\"{projectPath}\"", "--runtime", $"{RuntimeIdentifier.Current}"}.Concat(args));
|
||||
Dnx.RunRestore(new [] { $"\"{projectPath}\"", "--runtime", $"{DefaultRid}"}.Concat(args));
|
||||
}
|
||||
|
||||
private static string GenerateProjectJsonContents(IEnumerable<string> frameworks = null)
|
||||
|
|
19
test/E2E/E2E.xproj
Normal file
19
test/E2E/E2E.xproj
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0.24720" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.24720</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>65741cb1-8aee-4c66-8198-10a7ea0e4258</ProjectGuid>
|
||||
<RootNamespace>E2E</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
|
@ -10,6 +10,7 @@ using Xunit;
|
|||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.DotNet.Tests.EndToEnd
|
||||
{
|
||||
|
@ -33,7 +34,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
{
|
||||
TestSetup();
|
||||
|
||||
Rid = RuntimeIdentifier.Current;
|
||||
Rid = PlatformServices.Default.Runtime.GetLegacyRestoreRuntimeIdentifier();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
"Microsoft.DotNet.ProjectModel": { "target": "project" },
|
||||
"Microsoft.DotNet.Cli.Utils": { "target": "project" },
|
||||
|
||||
"Microsoft.DotNet.Tools.Tests.Utilities": { "target": "project" }
|
||||
},
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.IO;
|
|||
using System.Reflection;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using Microsoft.DotNet.ProjectModel.Loader;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using NuGet.Frameworks;
|
||||
|
||||
namespace LoadContextTest
|
||||
|
@ -23,7 +24,8 @@ namespace LoadContextTest
|
|||
|
||||
// Load the project load context
|
||||
Console.WriteLine($"Creating load context for {project}");
|
||||
var context = ProjectContext.Create(project, FrameworkConstants.CommonFrameworks.DnxCore50, new[] { RuntimeIdentifier.Current });
|
||||
var rid = PlatformServices.Default.Runtime.GetRuntimeIdentifier();
|
||||
var context = ProjectContext.Create(project, FrameworkConstants.CommonFrameworks.DnxCore50, new[] { rid });
|
||||
var loadContext = context.CreateLoadContext();
|
||||
|
||||
// Load the project assembly
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
"System.Linq": "4.0.1-beta-23516",
|
||||
"System.Threading": "4.0.11-beta-23516",
|
||||
|
||||
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-*",
|
||||
|
||||
"Microsoft.DotNet.ProjectModel.Loader": { "target": "project" }
|
||||
},
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ using Xunit;
|
|||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Publish.Tests
|
||||
{
|
||||
|
@ -24,11 +25,11 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
|
|||
{
|
||||
new object[] { "", "", "", "" },
|
||||
new object[] { "dnxcore50", "", "", "" },
|
||||
new object[] { "", RuntimeIdentifier.Current, "", "" },
|
||||
new object[] { "", PlatformServices.Default.Runtime.GetLegacyRestoreRuntimeIdentifier(), "", "" },
|
||||
new object[] { "", "", "Release", "" },
|
||||
new object[] { "", "", "", "some/dir"},
|
||||
//new object[] { "", "", "", "\"some/dir/with spaces\"" }, // issue - https://github.com/dotnet/cli/issues/525
|
||||
new object[] { "dnxcore50", RuntimeIdentifier.Current, "Debug", "some/dir" },
|
||||
new object[] { "dnxcore50", PlatformServices.Default.Runtime.GetLegacyRestoreRuntimeIdentifier(), "Debug", "some/dir" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,11 @@
|
|||
"xunit.netcore.extensions": "1.0.0-prerelease-*",
|
||||
"xunit.runner.utility": "2.1.0",
|
||||
|
||||
"Microsoft.DotNet.Tools.Tests.Utilities": { "target": "project" }
|
||||
|
||||
"Microsoft.DotNet.Tools.Tests.Utilities": { "target": "project" },
|
||||
"Microsoft.DotNet.Cli.Utils": {
|
||||
"target": "project",
|
||||
"type": "build"
|
||||
}
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
|
|
|
@ -10,6 +10,7 @@ using System.Threading.Tasks;
|
|||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||
{
|
||||
|
@ -55,7 +56,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
string config = string.IsNullOrEmpty(_config) ? "Debug" : _config;
|
||||
string framework = string.IsNullOrEmpty(_framework) ?
|
||||
_project.GetTargetFrameworks().First().FrameworkName.GetShortFolderName() : _framework;
|
||||
string runtime = string.IsNullOrEmpty(_runtime) ? RuntimeIdentifier.Current : _runtime;
|
||||
string runtime = string.IsNullOrEmpty(_runtime) ? PlatformServices.Default.Runtime.GetLegacyRestoreRuntimeIdentifier() : _runtime;
|
||||
string output = Path.Combine("bin", config, framework, runtime);
|
||||
|
||||
return output;
|
||||
|
|
Loading…
Reference in a new issue