From 44819532eaf5103e5ee0ef06884572555a64b54a Mon Sep 17 00:00:00 2001 From: Nick Guerrera Date: Wed, 16 Aug 2017 17:41:16 -0700 Subject: [PATCH 1/2] Disable multilevel lookup in build/test to prevent accidental machine dependencies --- build.ps1 | 3 +++ build.sh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/build.ps1 b/build.ps1 index 9b5e5fdb91cd..80dd415986a4 100644 --- a/build.ps1 +++ b/build.ps1 @@ -94,6 +94,9 @@ $env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH" # Disable first run since we want to control all package sources $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +# Don't resolve runtime, shared framework, or SDK from other locations +$env:DOTNET_MULTILEVEL_LOOKUP=0 + $logPath = "$RepoRoot\bin\log" if (!(Test-Path -Path $logPath)) { New-Item -Path $logPath -Force -ItemType 'Directory' | Out-Null diff --git a/build.sh b/build.sh index b41a16fedd38..7413eac8be56 100755 --- a/build.sh +++ b/build.sh @@ -92,4 +92,7 @@ export PATH="$DOTNET_INSTALL_DIR:$PATH" # Disable first run since we want to control all package sources export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +# Don't resolve runtime, shared framework, or SDK from global locations +export DOTNET_MULTILEVEL_LOOKUP=0 + dotnet msbuild $REPOROOT/build/build.proj /m:1 /nologo /p:Configuration=$CONFIGURATION /p:Platform="$PLATFORM" "${args[@]}" /warnaserror From f8d2186f3c48e63add882a7b240cced9d70cb160 Mon Sep 17 00:00:00 2001 From: Nick Guerrera Date: Fri, 18 Aug 2017 10:40:50 -0700 Subject: [PATCH 2/2] Bump default versions for self-contained apps --- .../Microsoft.NET.Sdk.DefaultItems.targets | 44 ++++++++++--------- .../GivenThatWeWantToBuildANetCoreApp.cs | 17 ++++--- test/Microsoft.NET.TestFramework/RepoInfo.cs | 14 ++++++ 3 files changed, 48 insertions(+), 27 deletions(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.DefaultItems.targets b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.DefaultItems.targets index 57ca8309b0a4..e15602e87a6f 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.DefaultItems.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.DefaultItems.targets @@ -76,29 +76,25 @@ Copyright (c) .NET Foundation. All rights reserved. If RuntimeFrameworkVersion is not specified, the following logic applies: - - When targeting .NET Core 2.0 or higher, Framework-dependent apps use the target framework version with a ".0" patch version - - When targeting .NET Core 2.0 or higher, Self-contained apps use the latest patch version (from when the SDK shipped) for - the specified major.minor version of .NET Core - - When targeting .NET Core 1.x, the latest patch version (from when the SDK shipped) is used for both Framework-dependent and - Self-contained apps. This is to preserve the same behavior between 1.x and 2.0 SDKs. If we ship further patch versions - after 1.0.5 and 1.1.2, we may choose to apply the Framework-dependent / Self-contained split to 1.x for those versions. + - Self-contained apps use the latest corrsesponding patch version (from when the SDK shipped) + + - When targeting .NET Core 2.0 or higher: + - Framework-dependent apps use the target framework version with a ".0" patch version + + - When targeting .NET Core 1.0 and 1.1 + - Framework-dependent apps use 1.0.5 and 1.1.2, respectively. + - This is done for compatibility with previous releases that bumped the self-contained and framework-dependent versions together. --> - + - 1.0.5 1.0.5 - 1.1.2 + Condition="'$(ImplicitRuntimeFrameworkVersionForSelfContainedNetCoreApp1_0)' == ''">1.0.6 1.1.2 + Condition="'$(ImplicitRuntimeFrameworkVersionForSelfContainedNetCoreApp1_1)' == ''">1.1.3 + 2.0.1 @@ -108,18 +104,24 @@ Copyright (c) .NET Foundation. All rights reserved. - $(ImplicitRuntimeFrameworkVersionForFrameworkDependentNetCoreApp1_0) + 1.0.5 $(ImplicitRuntimeFrameworkVersionForSelfContainedNetCoreApp1_0) - $(ImplicitRuntimeFrameworkVersionForFrameworkDependentNetCoreApp1_1) + 1.1.2 $(ImplicitRuntimeFrameworkVersionForSelfContainedNetCoreApp1_1) + + + 2.0 + $(ImplicitRuntimeFrameworkVersionForSelfContainedNetCoreApp2_0) + + - + $(BundledNETCoreAppPackageVersion) diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs index c7f51e9b1675..469b214eeece 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs @@ -48,15 +48,20 @@ public void It_targets_the_right_shared_framework(string targetFramework, string // Test behavior when implicit version differs for framework-dependent and self-contained apps [Theory] - [InlineData(false, true, "1.1.1")] - [InlineData(true, true, "1.1.2")] - [InlineData(false, false, "1.1.1")] - public void It_targets_the_right_framework_depending_on_output_type(bool selfContained, bool isExe, string expectedFrameworkVersion) + [InlineData("netcoreapp1.0", false, true, "1.0.5")] + [InlineData("netcoreapp1.0", true, true, RepoInfo.ImplicitRuntimeFrameworkVersionForSelfContainedNetCoreApp1_0)] + [InlineData("netcoreapp1.0", false, false, "1.0.5")] + [InlineData("netcoreapp1.1", false, true, "1.1.2")] + [InlineData("netcoreapp1.1", true, true, RepoInfo.ImplicitRuntimeFrameworkVersionForSelfContainedNetCoreApp1_1)] + [InlineData("netcoreapp1.1", false, false, "1.1.2")] + [InlineData("netcoreapp2.0", false, true, "2.0.0")] + [InlineData("netcoreapp2.0", true, true, RepoInfo.ImplicitRuntimeFrameworkVersionForSelfContainedNetCoreApp2_0)] + [InlineData("netcoreapp2.0", false, false, "2.0.0")] + public void It_targets_the_right_framework_depending_on_output_type(string targetFramework, bool selfContained, bool isExe, string expectedFrameworkVersion) { string testIdentifier = "Framework_targeting_" + (isExe ? "App_" : "Lib_") + (selfContained ? "SelfContained" : "FrameworkDependent"); - It_targets_the_right_framework(testIdentifier, "netcoreapp1.1", null, selfContained, isExe, expectedFrameworkVersion, expectedFrameworkVersion, - "/p:ImplicitRuntimeFrameworkVersionForFrameworkDependentNetCoreApp1_1=1.1.1"); + It_targets_the_right_framework(testIdentifier, targetFramework, null, selfContained, isExe, expectedFrameworkVersion, expectedFrameworkVersion); } private void It_targets_the_right_framework( diff --git a/test/Microsoft.NET.TestFramework/RepoInfo.cs b/test/Microsoft.NET.TestFramework/RepoInfo.cs index 21e7f81972c1..69b190018b96 100644 --- a/test/Microsoft.NET.TestFramework/RepoInfo.cs +++ b/test/Microsoft.NET.TestFramework/RepoInfo.cs @@ -134,6 +134,15 @@ private static string FindConfigurationInBasePath() return new DirectoryInfo(GetBaseDirectory()).Parent.Name; } + // For test purposes, override the implicit .NETCoreApp version for self-contained apps that to builds thare + // (1) different from the fixed framework-dependent defaults (1.0.5, 1.1.2, 2.0.0) + // (2) currently available on nuget.org + // + // This allows bumping the versions before builds without causing tests to fail. + public const string ImplicitRuntimeFrameworkVersionForSelfContainedNetCoreApp1_0 = "1.0.4"; + public const string ImplicitRuntimeFrameworkVersionForSelfContainedNetCoreApp1_1 = "1.1.1"; + public const string ImplicitRuntimeFrameworkVersionForSelfContainedNetCoreApp2_0 = "2.0.0-preview2-25407-01"; + public static string GetBaseDirectory() { #if NET451 @@ -160,6 +169,11 @@ public static ICommand AddTestEnvironmentVariables(ICommand command) "msbuildExtensions-ver", "Microsoft.Common.targets", "ImportAfter", "Microsoft.NET.Build.Extensions.targets")); command = command.EnvironmentVariable("MicrosoftNETBuildExtensionsTargets", Path.Combine(RepoInfo.BuildExtensionsMSBuildPath, "Microsoft.NET.Build.Extensions.targets")); + command = command + .EnvironmentVariable(nameof(ImplicitRuntimeFrameworkVersionForSelfContainedNetCoreApp1_0), ImplicitRuntimeFrameworkVersionForSelfContainedNetCoreApp1_0) + .EnvironmentVariable(nameof(ImplicitRuntimeFrameworkVersionForSelfContainedNetCoreApp1_1), ImplicitRuntimeFrameworkVersionForSelfContainedNetCoreApp1_1) + .EnvironmentVariable(nameof(ImplicitRuntimeFrameworkVersionForSelfContainedNetCoreApp2_0), ImplicitRuntimeFrameworkVersionForSelfContainedNetCoreApp2_0); + return command; } }