Enable building dotnet-CLI for centos.

I had to patch up a redhat dnx package which supports NETStandard.Library package. It is currently uploaded to dotnet-cli blob storage. This hack will no longer be required when we move to xplat nuget to do 'dotnet restore'. Apart from this there are three issues that are tracked for centos.
- compile-native not yet supported - https://github.com/dotnet/cli/issues/453
- dnu restore crashes intermittently on centos. I need to investigate this a little bit more and file issues on dnx or coreclr. This will make our CI builds very flaky.
- Dotnet restore does not restore native shims when using “centos.7-x64” - https://github.com/dotnet/corefx/issues/5066
This commit is contained in:
Sridhar Periyasamy 2015-12-18 11:32:20 -08:00
parent 3b9828404e
commit 1db27b7ae3
5 changed files with 93 additions and 25 deletions

View file

@ -1,6 +1,8 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace Microsoft.DotNet.ProjectModel
@ -18,13 +20,50 @@ namespace Microsoft.DotNet.ProjectModel
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return "ubuntu.14.04-x64";
if(IsCentOS())
{
return "centos.7.1-x64";
}
else if(IsUbuntu())
{
return "ubuntu.14.04-x64";
}
else
{
// unknown distro. Lets fail fast
throw new InvalidOperationException("Current linux distro is not supported.");
}
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
return "osx.10.10-x64";
}
return "unknown";
throw new InvalidOperationException("Current operating system is not supported.");
}
private static bool IsCentOS()
{
return IsLinuxDistro("centos");
}
private static bool IsUbuntu()
{
return IsLinuxDistro("ubuntu");
}
private static bool IsLinuxDistro(string distro)
{
// HACK - A file which can be found in most linux distros
// Did not test in non-en distros
const string OSIDFILE = "/etc/os-release";
if(!File.Exists(OSIDFILE))
{
return false;
}
return File.ReadAllText(OSIDFILE).ToLower().Contains(distro);
}
}
}