Specify sdk version, use nuget cache (dotnet/core-setup#8497)
authorViktor Hofer <viktor.hofer@microsoft.com>
Thu, 17 Oct 2019 22:09:01 +0000 (00:09 +0200)
committerGitHub <noreply@github.com>
Thu, 17 Oct 2019 22:09:01 +0000 (00:09 +0200)
* Use global dotnet installation if matching

Arcade guarantees that the requested version specified in global.json
is installed.

* Enforce a minimum dotnet sdk version

Specify a minimum dotnet sdk version in the sdk section global.json
which is honored by the Desktop msbuild as well. Set a roll-forward
policy so that a globally installed sdk with a more recent version can
be used when invoking a project directly.

* Use the user's nuget cache for local builds

Other dotnet repositories like CoreFx are already using the user's
nuget cache for local builds vs the repo local cache for CI builds
and no problems were reported. Switching to remove differences in builds

* Write out a test-local global.json file to ensure that the tests don't use the repo's global.json.

Commit migrated from https://github.com/dotnet/core-setup/commit/85814dcc1bbd94612f57ad5db497d51032e34894

src/installer/test/HostActivation.Tests/MultilevelSDKLookup.cs
src/installer/test/HostActivation.Tests/SDKLookup.cs

index b84ae77..4b7ff70 100644 (file)
@@ -453,6 +453,8 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation
                 return;
             }
 
+            WriteEmptyGlobalJson();
+
             // Add SDK versions
             AddAvailableSdkVersions(_regSdkBaseDir, "9999.0.4");
 
@@ -516,6 +518,8 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation
                 return;
             }
 
+            WriteEmptyGlobalJson();
+
             using (var registeredInstallLocationOverride = new RegisteredInstallLocationOverride(DotNet.GreatestVersionHostFxrFilePath))
             {
                 registeredInstallLocationOverride.SetInstallLocation(_regDir, RepoDirectories.BuildArchitecture);
@@ -552,6 +556,8 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation
                 return;
             }
 
+            WriteEmptyGlobalJson();
+
             // Add SDK versions
             AddAvailableSdkVersions(_regSdkBaseDir, "9999.0.0", "9999.0.3-dummy");
 
@@ -730,5 +736,12 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation
 
             File.Copy(srcFile, destFile, true);
         }
+
+        private void WriteGlobalJson(string contents)
+        {
+            File.WriteAllText(Path.Combine(_currentWorkingDir, "global.json"), contents);
+        }
+
+        private void WriteEmptyGlobalJson() => WriteGlobalJson("{}");
     }
 }
index 6eecedd..f0ac42e 100644 (file)
@@ -62,7 +62,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation
             Directory.CreateDirectory(_cwdSdkBaseDir);
             Directory.CreateDirectory(_userSdkBaseDir);
             Directory.CreateDirectory(_exeSdkBaseDir);
-            
+
             // Trace messages used to identify from which folder the SDK was picked
             _exeSelectedMessage = $"Using .NET Core SDK dll=[{_exeSdkBaseDir}";
         }
@@ -370,6 +370,8 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation
         [Fact]
         public void SdkLookup_Negative_Version()
         {
+            WriteEmptyGlobalJson();
+
             // Add a negative SDK version
             AddAvailableSdkVersions(_exeSdkBaseDir, "-1.-1.-1");
 
@@ -420,6 +422,8 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation
         [Fact]
         public void SdkLookup_Must_Pick_The_Highest_Semantic_Version()
         {
+            WriteEmptyGlobalJson();
+            
             // Add SDK versions
             AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.0", "9999.0.3-dummy.9", "9999.0.3-dummy.10");
 
@@ -569,6 +573,8 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation
         {
             const string Requested = "9999.0.100";
 
+            WriteEmptyGlobalJson();
+
             AddAvailableSdkVersions(_exeSdkBaseDir, Requested);
 
             WriteGlobalJson(FormatGlobalJson(policy: rollForward, version: Requested));
@@ -1285,5 +1291,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation
         {
             File.WriteAllText(Path.Combine(_currentWorkingDir, "global.json"), contents);
         }
+        
+        private void WriteEmptyGlobalJson() => WriteGlobalJson("{}");
     }
 }