Skip to content

Commit

Permalink
Merge pull request #924 from DustinCampbell/update-build
Browse files Browse the repository at this point in the history
Several updates to build
  • Loading branch information
DustinCampbell authored Jul 24, 2017
2 parents 15c0f51 + 5d2c8d6 commit d3d1915
Show file tree
Hide file tree
Showing 14 changed files with 357 additions and 198 deletions.
46 changes: 3 additions & 43 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,15 @@ dist: trusty
env:
global:
secure: m2PtYwYOhaK0uFMZ19ZxApZwWZeAIq1dS//jx/5I3txpIWD+TfycQMAWYxycFJ/GJkeVF29P4Zz1uyS2XKKjPJpp2Pds98FNQyDv3OftpLAVa0drsjfhurVlBmSdrV7GH6ncKfvhd+h7KVK5vbZc+NeR4dH7eNvN/jraS//AMJg=
mono:
- 4.8.0
mono: beta
dotnet: 1.0.4
os:
- linux
- osx
osx_image: xcode7.3

# Ensure MSBuild is installed
before_install:
- |
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get -qq update
sudo apt-get install msbuild
fi
- |
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
brew update
brew install jq
brew install openssl
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
brew list
fi
- |
# This is a temporary fix to workaround a problem where Travis picks up a build of Mono on OSX that
# includes a broken version of MSBuild.
#
# See https://github.com/mono/msbuild/commit/cff4013ba3a69f82dc0ae96b3e15af700d8f74ef
# for the fix this is replicating.
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
MSBUILD_BIN=/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/msbuild/15.0/bin
if [ ! -d $MSBUILD_BIN ] || [ -f $MSBUILD_BIN/System.Reflection.Metadata.dll ]; then
echo "WORKAROUND: Time to remove System.Reflection.Metadata.dll workaround"
else
echo "WORKAROUND: Copying System.Reflection.Metadata.dll to Mono MSBuild"
sudo cp $MSBUILD_BIN/Roslyn/System.Reflection.Metadata.dll $MSBUILD_BIN/System.Reflection.Metadata.dll
fi
fi
- msbuild /version

script:
- travis_retry ./build.sh --target TravisTestAll
- ./build.sh --target Travis --archive
- ./build.sh --target All --archive

addons:
apt:
Expand Down
10 changes: 2 additions & 8 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In order to build OmniSharp, the [.NET 4.6 targeting pack](http://go.microsoft.c

## macOS

**Mono 4.8.0** or greater is required. You can install this using the latest [.pkg](http://www.mono-project.com/download/#download-mac) or install it view [Homebrew](https://brew.sh/):
**Mono 5.2.0** or greater is required. You can install this using the latest [.pkg](http://www.mono-project.com/download/#download-mac) or install it view [Homebrew](https://brew.sh/):

```
brew update
Expand All @@ -18,13 +18,7 @@ brew install caskroom/cask/mono-mdk

Because OmniSharp uses the .NET Core SDK as part of the build, not all Linux distros are supported. A good rule of thumb is to check the list [here](https://www.microsoft.com/net/download/linux) to see if your particular distro is supported.

**Mono 4.8.0** or greater is required. Each distro or derivative has it's own set of instructions for installing Mono which you can find [here](http://www.mono-project.com/download/#download-lin).

In addition, the `msbuild` package must be installed. On Debian, Ubuntu, and derivatives, this can be achieved by first adding the Mono Project GPG signing key and package repository using the instructions [here](http://www.mono-project.com/docs/getting-started/install/linux/#debian-ubuntu-and-derivatives). Then, install msbuild via apt-get.

```
sudo apt-get install msbuild
```
**Mono 5.2.0** or greater is required. Each distro or derivative has it's own set of instructions for installing Mono which you can find [here](http://www.mono-project.com/download/#download-lin).

# Usage

Expand Down
109 changes: 64 additions & 45 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#load "scripts/archiving.cake"
#load "scripts/artifacts.cake"
#load "scripts/msbuild.cake"
#load "scripts/platform.cake"
#load "scripts/validation.cake"

using System.ComponentModel;
using System.Net;
Expand All @@ -12,15 +14,17 @@ var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var testConfiguration = Argument("test-configuration", "Debug");
var installFolder = Argument("install-path",
CombinePaths(Environment.GetEnvironmentVariable(IsRunningOnWindows() ? "USERPROFILE" : "HOME"), ".omnisharp", "local"));
CombinePaths(Environment.GetEnvironmentVariable(Platform.Current.IsWindows ? "USERPROFILE" : "HOME"), ".omnisharp", "local"));
var requireArchive = HasArgument("archive");
var useGlobalDotNetSdk = HasArgument("use-global-dotnet-sdk");

Log.Context = Context;

var env = new BuildEnvironment(IsRunningOnWindows(), useGlobalDotNetSdk);
var env = new BuildEnvironment(useGlobalDotNetSdk);
var buildPlan = BuildPlan.Load(env);

Information("Current platform: {0}", Platform.Current);

/// <summary>
/// Clean artifacts.
/// </summary>
Expand Down Expand Up @@ -64,7 +68,7 @@ Task("PopulateRuntimes")
.IsDependentOn("BuildEnvironment")
.Does(() =>
{
if (IsRunningOnWindows() && string.Equals(Environment.GetEnvironmentVariable("APPVEYOR"), "True"))
if (Platform.Current.IsWindows && string.Equals(Environment.GetEnvironmentVariable("APPVEYOR"), "True"))
{
buildPlan.SetTargetRids(
"default", // To allow testing the published artifact
Expand Down Expand Up @@ -95,34 +99,44 @@ Task("PopulateRuntimes")

void ParseDotNetInfoValues(IEnumerable<string> lines, out string version, out string rid, out string basePath)
{
var keyValueMap = new Dictionary<string, string>();
version = null;
rid = null;
basePath = null;

foreach (var line in lines)
{
var index = line.IndexOf(":");
if (index >= 0)
var colonIndex = line.IndexOf(':');
if (colonIndex >= 0)
{
var key = line.Substring(0, index).Trim();
var value = line.Substring(index + 1).Trim();
var name = line.Substring(0, colonIndex).Trim();
var value = line.Substring(colonIndex + 1).Trim();

if (!string.IsNullOrEmpty(key) &&
!string.IsNullOrEmpty(value))
if (string.IsNullOrWhiteSpace(version) && name.Equals("Version", StringComparison.OrdinalIgnoreCase))
{
version = value;
}
else if (string.IsNullOrWhiteSpace(rid) && name.Equals("RID", StringComparison.OrdinalIgnoreCase))
{
rid = value;
}
else if (string.IsNullOrWhiteSpace(basePath) && name.Equals("Base Path", StringComparison.OrdinalIgnoreCase))
{
keyValueMap.Add(key, value);
basePath = value;
}
}
}

if (!keyValueMap.TryGetValue("Version", out version))
if (string.IsNullOrWhiteSpace(version))
{
throw new Exception("Could not locate Version in 'dotnet --info' output.");
}

if (!keyValueMap.TryGetValue("RID", out rid))
if (string.IsNullOrWhiteSpace(rid))
{
throw new Exception("Could not locate RID in 'dotnet --info' output.");
}

if (!keyValueMap.TryGetValue("Base Path", out basePath))
if (string.IsNullOrWhiteSpace(basePath))
{
throw new Exception("Could not locate Base Path in 'dotnet --info' output.");
}
Expand All @@ -144,7 +158,7 @@ void InstallDotNetSdk(BuildEnvironment env, BuildPlan plan, string version, stri
client.DownloadFile(url, scriptFilePath);
}

if (!IsRunningOnWindows())
if (!Platform.Current.IsWindows)
{
Run("chmod", $"+x '{scriptFilePath}'");
}
Expand All @@ -166,10 +180,7 @@ void InstallDotNetSdk(BuildEnvironment env, BuildPlan plan, string version, stri
Run(env.ShellCommand, $"{env.ShellArgument} {scriptFilePath} {string.Join(" ", argList)}").ExceptionOnError($"Failed to Install .NET Core SDK {version}");
}

/// <summary>
/// Install/update build environment.
/// </summary>
Task("BuildEnvironment")
Task("InstallDotNetCoreSdk")
.Does(() =>
{
if (!useGlobalDotNetSdk)
Expand All @@ -184,6 +195,9 @@ Task("BuildEnvironment")
version: buildPlan.LegacyDotNetVersion,
installFolder: env.Folders.LegacyDotNetSdk);

string DOTNET_CLI_UI_LANGUAGE = "DOTNET_CLI_UI_LANGUAGE";
var originalUILanguageValue = Environment.GetEnvironmentVariable(DOTNET_CLI_UI_LANGUAGE);
Environment.SetEnvironmentVariable(DOTNET_CLI_UI_LANGUAGE, "en-US");

// Capture 'dotnet --info' output and parse out RID.
var lines = new List<string>();
Expand All @@ -196,6 +210,10 @@ Task("BuildEnvironment")
{
throw new Exception("Failed to run 'dotnet --info'");
}
finally
{
Environment.SetEnvironmentVariable(DOTNET_CLI_UI_LANGUAGE, originalUILanguageValue);
}

string version, rid, basePath;
ParseDotNetInfoValues(lines, out version, out rid, out basePath);
Expand All @@ -214,6 +232,25 @@ Task("BuildEnvironment")
Information(" Base Path: {0}", basePath);
});

Task("ValidateEnvironment")
.Does(() =>
{
if (!Platform.Current.IsWindows)
{
ValidateMonoVersion(buildPlan);
}
});

/// <summary>
/// Install/update build environment.
/// </summary>
Task("BuildEnvironment")
.IsDependentOn("ValidateEnvironment")
.IsDependentOn("InstallDotNetCoreSdk")
.Does(() =>
{
});

/// <summary>
/// Restore required NuGet packages.
/// </summary>
Expand Down Expand Up @@ -266,13 +303,13 @@ Task("PrepareTestAssets")

void BuildProject(BuildEnvironment env, string projectName, string projectFilePath, string configuration)
{
var command = IsRunningOnWindows()
var command = Platform.Current.IsWindows
? env.DotNetCommand
: env.ShellCommand;

var arguments = IsRunningOnWindows()
var arguments = Platform.Current.IsWindows
? $"build \"{projectFilePath}\" --configuration {configuration} /v:d"
: $"{env.ShellArgument} msbuild.{env.ShellScriptFileExtension} \"{projectFilePath}\" /p:Configuration={configuration} /v:d";
: $"{env.ShellArgument} msbuild \"{projectFilePath}\" /p:Configuration={configuration} /v:d";

var logFileName = CombinePaths(env.Folders.ArtifactsLogs, $"{projectName}-build.log");

Expand Down Expand Up @@ -319,13 +356,6 @@ Task("TestAll")
.IsDependentOn("TestCore")
.Does(() =>{});

/// <summary>
/// Run all tests for Travis CI .NET Desktop and .NET Core
/// </summary>
Task("TravisTestAll")
.IsDependentOn("Cleanup")
.IsDependentOn("TestAll");

/// <summary>
/// Run tests for .NET Core (using .NET CLI).
/// </summary>
Expand Down Expand Up @@ -370,7 +400,7 @@ Task("Test")
var logFile = CombinePaths(env.Folders.ArtifactsLogs, $"{testProject}-desktop-result.xml");
var arguments = $"\"{targetPath}\" -parallel none -xml \"{logFile}\" -notrait category=failing";

if (IsRunningOnWindows())
if (Platform.Current.IsWindows)
{
Run(xunitInstancePath, arguments, instanceFolder)
.ExceptionOnError($"Test {testProject} failed for net46");
Expand All @@ -380,15 +410,15 @@ Task("Test")
// Copy the Mono-built Microsoft.Build.* binaries to the test folder.
DirectoryHelper.Copy($"{env.Folders.MonoMSBuildLib}", instanceFolder);

Run("mono", $"\"{xunitInstancePath}\" {arguments}", instanceFolder)
Run("mono", $"--assembly-loader=strict \"{xunitInstancePath}\" {arguments}", instanceFolder)
.ExceptionOnError($"Test {testProject} failed for net46");
}
}
});

bool IsNetFrameworkOnUnix(string framework)
{
return !IsRunningOnWindows()
return !Platform.Current.IsWindows
&& !framework.StartsWith("netcore")
&& !framework.StartsWith("netstandard");
}
Expand Down Expand Up @@ -469,7 +499,7 @@ Task("OnlyPublish")
var args = GetPublishArguments(projectFileName, rid, framework, configuration, outputFolder);

args = IsNetFrameworkOnUnix(framework)
? $"{env.ShellArgument} msbuild.{env.ShellScriptFileExtension} {args}"
? $"{env.ShellArgument} msbuild {args}"
: args;

Information("Publishing {0} for {1}/{2}...", projectName, framework, rid);
Expand All @@ -481,7 +511,7 @@ Task("OnlyPublish")
DirectoryHelper.Copy($"{env.Folders.MSBuildBase}-{framework}", CombinePaths(outputFolder, "msbuild"));

// For OSX/Linux net46 builds, copy the MSBuild libraries built for Mono.
if (!IsRunningOnWindows() && framework == "net46")
if (!Platform.Current.IsWindows && framework == "net46")
{
DirectoryHelper.Copy($"{env.Folders.MonoMSBuildLib}", outputFolder);
}
Expand Down Expand Up @@ -612,17 +642,6 @@ Task("Local")
.IsDependentOn("LocalPublish")
.IsDependentOn("TestPublished");

/// <summary>
/// Build centered around producing the final artifacts for Travis
///
/// The tests are run as a different task "TestAll"
/// </summary>
Task("Travis")
.IsDependentOn("Cleanup")
.IsDependentOn("Restore")
.IsDependentOn("AllPublish")
.IsDependentOn("TestPublished");

/// <summary>
/// Default Task aliases to Local.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions build.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"DotNetChannel": "preview",
"DotNetVersion": "1.0.4",
"LegacyDotNetVersion": "1.0.0-preview2-1-003177",
"RequiredMonoVersion": "5.2.0.196",
"DownloadURL": "https://omnisharpdownload.blob.core.windows.net/ext",
"MSBuildRuntimeForMono": "Microsoft.Build.Runtime.Mono-alpha4.zip",
"MSBuildLibForMono": "Microsoft.Build.Lib.Mono-alpha4.zip",
Expand Down
11 changes: 0 additions & 11 deletions msbuild.sh

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit d3d1915

Please sign in to comment.