Skip to content

Commit

Permalink
Update build script to use legacy .NET Core SDK to restore project.js…
Browse files Browse the repository at this point in the history
…on test proejcts
  • Loading branch information
DustinCampbell committed Mar 7, 2017
1 parent f807313 commit bbd8b33
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ scripts/Omnisharp*

# Build folder
.dotnet/
.dotnet-legacy/
tools/*
!tools/packages.config

Expand Down
49 changes: 45 additions & 4 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#load "scripts/runhelpers.cake"
#load "scripts/archiving.cake"
#load "scripts/artifacts.cake"
#load "scripts/nuget.cake"

using System.ComponentModel;
using System.Net;
Expand Down Expand Up @@ -32,6 +31,7 @@ public class BuildPlan
public string DotNetInstallScriptURL { get; set; }
public string DotNetChannel { get; set; }
public string DotNetVersion { get; set; }
public string LegacyDotNetVersion { get; set; }
public string DownloadURL { get; set; }
public string MSBuildRuntimeForMono { get; set; }
public string MSBuildLibForMono { get; set; }
Expand Down Expand Up @@ -337,7 +337,7 @@ Task("BuildEnvironment")
var scriptFilePath = CombinePaths(env.Folders.DotNetSdk, scriptFileName);
var url = $"{buildPlan.DotNetInstallScriptURL}/{scriptFileName}";
Information("Downloading .NET CLI install script...");
Information("Downloading .NET Core SDK install script...");
using (var client = new WebClient())
{
Expand Down Expand Up @@ -366,7 +366,47 @@ Task("BuildEnvironment")
argList.Add(env.Folders.DotNetSdk);
}
Information("Launching .NET CLI install script...");
Information("Launching .NET Core SDK install script...");
Run(env.ShellCommand, $"{env.ShellArgument} {scriptFilePath} {string.Join(" ", argList)}");
}
// Install legacy .NET Core SDKs
if (!DirectoryExists(env.Folders.LegacyDotNetSdk))
{
CreateDirectory(env.Folders.LegacyDotNetSdk);
var scriptFileName = $"dotnet-install.{env.ShellScriptFileExtension}";
var scriptFilePath = CombinePaths(env.Folders.LegacyDotNetSdk, scriptFileName);
var url = $"{buildPlan.DotNetInstallScriptURL}/{scriptFileName}";
Information("Downloading legacy .NET Core SDK install script...");
using (var client = new WebClient())
{
client.DownloadFile(url, scriptFilePath);
}
if (!IsRunningOnWindows())
{
Run("chmod", $"+x '{scriptFilePath}'");
}
var argList = new List<string>();
argList.Add("-Channel");
argList.Add(buildPlan.DotNetChannel);
if (!string.IsNullOrEmpty(buildPlan.LegacyDotNetVersion))
{
argList.Add("-Version");
argList.Add(buildPlan.LegacyDotNetVersion);
}
argList.Add("-InstallDir");
argList.Add(env.Folders.LegacyDotNetSdk);
Information("Launching legacy .NET Core SDK install script...");
Run(env.ShellCommand, $"{env.ShellArgument} {scriptFilePath} {string.Join(" ", argList)}");
}
Expand Down Expand Up @@ -409,7 +449,8 @@ Task("Restore")
foreach (var project in buildPlan.TestAssetsToRestoreWithNuGet3)
{
var folder = CombinePaths(env.Folders.TestAssets, "test-projects", project);
NuGetRestore(folder);
RunRestore(env.LegacyDotNetCommand, "restore", folder)
.ExceptionOnError($"Failed to restore '{folder}'.");
}
});

Expand Down
1 change: 1 addition & 0 deletions build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"DotNetInstallScriptURL": "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain",
"DotNetChannel": "preview",
"DotNetVersion": "1.0.0-rc4-004842",
"LegacyDotNetVersion": "1.0.0-preview2-1-003177",
"DownloadURL": "https://omnisharpdownload.blob.core.windows.net/ext",
"MSBuildRuntimeForMono": "Microsoft.Build.Runtime.Mono-alpha3.zip",
"MSBuildLibForMono": "Microsoft.Build.Lib.Mono-alpha3.zip",
Expand Down
5 changes: 5 additions & 0 deletions scripts/common.cake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ string CombinePaths(params string[] paths)
public class Folders
{
public string DotNetSdk { get; }
public string LegacyDotNetSdk { get; }
public string Tools { get; }

public string MSBuild { get; }
Expand All @@ -31,6 +32,7 @@ public class Folders
public Folders(string workingDirectory)
{
this.DotNetSdk = PathHelper.Combine(workingDirectory, ".dotnet");
this.LegacyDotNetSdk = PathHelper.Combine(workingDirectory, ".dotnet-legacy");
this.Tools = PathHelper.Combine(workingDirectory, "tools");

this.MSBuild = PathHelper.Combine(workingDirectory, "msbuild");
Expand All @@ -52,6 +54,7 @@ public class BuildEnvironment
public Folders Folders { get; }

public string DotNetCommand { get; }
public string LegacyDotNetCommand { get; }

public string ShellCommand { get; }
public string ShellArgument { get; }
Expand All @@ -67,6 +70,8 @@ public class BuildEnvironment
? "dotnet"
: PathHelper.Combine(this.Folders.DotNetSdk, "dotnet");

this.LegacyDotNetCommand = PathHelper.Combine(this.Folders.LegacyDotNetSdk, "dotnet");

this.ShellCommand = isWindows ? "powershell" : "bash";
this.ShellArgument = isWindows ? "-NoProfile /Command" : "-C";
this.ShellScriptFileExtension = isWindows ? "ps1" : "sh";
Expand Down
11 changes: 0 additions & 11 deletions scripts/nuget.cake

This file was deleted.

0 comments on commit bbd8b33

Please sign in to comment.