Skip to content

Commit

Permalink
On OSX/Linux, copy over MSBuild libraries with special Mono MSBuild b…
Browse files Browse the repository at this point in the history
…uild for net46
  • Loading branch information
DustinCampbell committed Dec 13, 2016
1 parent 4d5caed commit 9d2617f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
39 changes: 29 additions & 10 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public class BuildPlan
public string DotNetChannel { get; set; }
public string DotNetVersion { get; set; }
public string DownloadURL { get; set; }
public string MSBuildForMono { get; set; }
public string MSBuildRuntimeForMono { get; set; }
public string MSBuildLibForMono { get; set; }
public string[] Frameworks { get; set; }
public string[] Rids { get; set; }
public string MainProject { get; set; }
Expand Down Expand Up @@ -70,6 +71,8 @@ var packagesFolder = System.IO.Path.Combine(workingDirectory, buildPlan.Packages
var msbuildBaseFolder = System.IO.Path.Combine(workingDirectory, ".msbuild");
var msbuildNet46Folder = msbuildBaseFolder + "-net46";
var msbuildNetCoreAppFolder = msbuildBaseFolder + "-netcoreapp1.0";
var msbuildRuntimeForMonoInstallFolder = System.IO.Path.Combine(packagesFolder, "Microsoft.Build.Runtime.Mono");
var msbuildLibForMonoInstallFolder = System.IO.Path.Combine(packagesFolder, "Microsoft.Build.Lib.Mono");

/// <summary>
/// Clean artifacts.
Expand Down Expand Up @@ -114,25 +117,35 @@ Task("AcquirePackages")
noCache: true,
outputDirectory: $"\"{packagesFolder}\"");

var msbuildMonoInstallFolder = System.IO.Path.Combine(packagesFolder, "Microsoft.Build.Runtime.Mono");
if (!IsRunningOnWindows())
{
if (DirectoryExists(msbuildMonoInstallFolder))
if (DirectoryExists(msbuildRuntimeForMonoInstallFolder))
{
DeleteDirectory(msbuildMonoInstallFolder, recursive: true);
DeleteDirectory(msbuildRuntimeForMonoInstallFolder, recursive: true);
}

CreateDirectory(msbuildMonoInstallFolder);
if (DirectoryExists(msbuildLibForMonoInstallFolder))
{
DeleteDirectory(msbuildLibForMonoInstallFolder, recursive: true);
}

var msbuildMonoZip = System.IO.Path.Combine(msbuildMonoInstallFolder, buildPlan.MSBuildForMono);
CreateDirectory(msbuildRuntimeForMonoInstallFolder);
CreateDirectory(msbuildLibForMonoInstallFolder);

var msbuildMonoRuntimeZip = System.IO.Path.Combine(msbuildRuntimeForMonoInstallFolder, buildPlan.MSBuildRuntimeForMono);
var msbuildMonoLibZip = System.IO.Path.Combine(msbuildLibForMonoInstallFolder, buildPlan.MSBuildLibForMono);

using (var client = new WebClient())
{
client.DownloadFile($"{buildPlan.DownloadURL}/{buildPlan.MSBuildForMono}", msbuildMonoZip);
client.DownloadFile($"{buildPlan.DownloadURL}/{buildPlan.MSBuildRuntimeForMono}", msbuildMonoRuntimeZip);
client.DownloadFile($"{buildPlan.DownloadURL}/{buildPlan.MSBuildLibForMono}", msbuildMonoLibZip);
}

Unzip(msbuildMonoZip, msbuildMonoInstallFolder);
DeleteFile(msbuildMonoZip);
Unzip(msbuildMonoRuntimeZip, msbuildRuntimeForMonoInstallFolder);
Unzip(msbuildMonoLibZip, msbuildLibForMonoInstallFolder);

DeleteFile(msbuildMonoRuntimeZip);
DeleteFile(msbuildMonoLibZip);
}

if (DirectoryExists(msbuildNet46Folder))
Expand All @@ -159,7 +172,7 @@ Task("AcquirePackages")
}
else
{
CopyDirectory(msbuildMonoInstallFolder, msbuildNet46Folder);
CopyDirectory(msbuildRuntimeForMonoInstallFolder, msbuildNet46Folder);
}

CopyDirectory(msbuildNetCoreAppInstallFolder, msbuildNetCoreAppFolder);
Expand Down Expand Up @@ -475,6 +488,12 @@ Task("OnlyPublish")
// Copy MSBuild and SDKs to output
CopyDirectory($"{msbuildBaseFolder}-{framework}", System.IO.Path.Combine(outputFolder, "msbuild"));
// For OSX/Linux net46 builds, copy the MSBuild libraries built for Mono.
if (!IsRunningOnWindows() && framework == "net46")
{
CopyDirectory($"{msbuildLibForMonoInstallFolder}", outputFolder);
}
if (requireArchive)
{
Package(runtime, framework, outputFolder, packageFolder, buildPlan.MainProject.ToLower());
Expand Down
3 changes: 2 additions & 1 deletion build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"DotNetChannel": "preview",
"DotNetVersion": "1.0.0-preview2-003131",
"DownloadURL": "https://omnisharpdownload.blob.core.windows.net/ext",
"MSBuildForMono": "Microsoft.Build.Runtime.Mono-alpha1.zip",
"MSBuildRuntimeForMono": "Microsoft.Build.Runtime.Mono-alpha1.zip",
"MSBuildLibForMono": "Microsoft.Build.Lib.Mono-alpha1.zip",
"BuildToolsFolder": ".tools",
"ArtifactsFolder": "artifacts",
"PackagesFolder": "packages",
Expand Down

0 comments on commit 9d2617f

Please sign in to comment.