t Convert Test Assets to Microsoft.NETCore.App

fix dotnet-compile-fsc failures

fix test failures
This commit is contained in:
Bryan Thornbury 2016-04-12 17:29:07 -07:00
parent b682ab1d4f
commit 83d78129db
125 changed files with 483 additions and 492 deletions

View file

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Linq;
using System.Runtime.InteropServices;
using Microsoft.DotNet.Cli.Build.Framework;
@ -35,6 +36,26 @@ namespace Microsoft.DotNet.Cli.Build
"vbc.exe"
};
public static readonly string[] HostPackageSupportedRids = new[]
{
"win7-x64",
"win7-x86",
"osx.10.10-x64",
"osx.10.11-x64",
"ubuntu.14.04-x64",
"centos.7-x64",
"rhel.7-x64",
"rhel.7.2-x64",
"debian.8-x64"
};
public static readonly string[] HostPackages = new[]
{
"Microsoft.NETCore.DotNetHost",
"Microsoft.NETCore.DotNetHostPolicy",
"Microsoft.NETCore.DotNetHostResolver"
};
public const string SharedFrameworkName = "Microsoft.NETCore.App";
public static Crossgen CrossgenUtil = new Crossgen(CoreCLRVersion);
@ -58,6 +79,33 @@ namespace Microsoft.DotNet.Cli.Build
return c.Success();
}
// We need to generate stub host packages so we can restore our standalone test assets against the metapackage
// we built earlier in the build
// https://github.com/dotnet/cli/issues/2438
[Target]
public static BuildTargetResult GenerateStubHostPackages(BuildTargetContext c)
{
string currentRid = GetRuntimeId();
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion");
foreach (var hostPackageId in HostPackages)
{
foreach (var rid in HostPackageSupportedRids)
{
if (! rid.Equals(currentRid))
{
CreateDummyRuntimeNuGetPackage(
DotNetCli.Stage0,
hostPackageId,
rid,
buildVersion.HostNuGetPackageVersion,
Dirs.CorehostDummyPackages);
}
}
}
return c.Success();
}
private static string HostVer = "1.0.1";
private static string HostPolicyVer = "1.0.1";
private static string HostFxrVer = "1.0.1";
@ -146,7 +194,7 @@ namespace Microsoft.DotNet.Cli.Build
return c.Success();
}
[Target]
[Target(nameof(CompileTargets.GenerateStubHostPackages))]
public static BuildTargetResult PackagePkgProjects(BuildTargetContext c)
{
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion");
@ -158,7 +206,8 @@ namespace Microsoft.DotNet.Cli.Build
var content = $@"{c.BuildContext["CommitHash"]}{Environment.NewLine}{version}{Environment.NewLine}";
var pkgDir = Path.Combine(c.BuildContext.BuildDirectory, "pkg");
File.WriteAllText(Path.Combine(pkgDir, "version.txt"), content);
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (CurrentPlatform.IsWindows)
{
Command.Create(Path.Combine(pkgDir, "pack.cmd"))
// Workaround to arg escaping adding backslashes for arguments to .cmd scripts.
@ -305,6 +354,50 @@ namespace Microsoft.DotNet.Cli.Build
return c.Success();
}
private static void CreateDummyRuntimeNuGetPackage(DotNetCli dotnet, string basePackageId, string rid, string version, string outputDir)
{
var packageId = $"runtime.{rid}.{basePackageId}";
var projectJson = new StringBuilder();
projectJson.Append("{");
projectJson.Append($" \"version\": \"{version}\",");
projectJson.Append($" \"name\": \"{packageId}\",");
projectJson.Append(" \"dependencies\": { \"NETStandard.Library\": \"1.5.0-rc2-24008\" },");
projectJson.Append(" \"frameworks\": { \"netcoreapp1.0\": { \"imports\": [\"netstandard1.5\", \"dnxcore50\"] } },");
projectJson.Append($" \"runtimes\": {{ \"{rid}\": {{ }} }},");
projectJson.Append("}");
var programCs = "using System; namespace ConsoleApplication { public class Program { public static void Main(string[] args) { Console.WriteLine(\"Hello World!\"); } } }";
var tempPjDirectory = Path.Combine(Dirs.Intermediate, "dummyNuGetPackageIntermediate");
FS.Rmdir(tempPjDirectory);
Directory.CreateDirectory(tempPjDirectory);
var tempPjFile = Path.Combine(tempPjDirectory, "project.json");
var tempSourceFile = Path.Combine(tempPjDirectory, "Program.cs");
File.WriteAllText(tempPjFile, projectJson.ToString());
File.WriteAllText(tempSourceFile, programCs.ToString());
dotnet.Restore("--verbosity", "verbose", "--disable-parallel")
.WorkingDirectory(tempPjDirectory)
.Execute()
.EnsureSuccessful();
dotnet.Build(tempPjFile, "--runtime", rid)
.WorkingDirectory(tempPjDirectory)
.Execute()
.EnsureSuccessful();
dotnet.Pack(
tempPjFile, "--no-build",
"--output", outputDir)
.WorkingDirectory(tempPjDirectory)
.Execute()
.EnsureSuccessful();
}
private static void CleanOutputDir(string directory)
{
foreach (var file in FilesToClean)
@ -346,7 +439,11 @@ namespace Microsoft.DotNet.Cli.Build
string SharedFrameworkSourceRoot = GenerateSharedFrameworkProject(c, SharedFrameworkTemplateSourceRoot, sharedFrameworkRid);
dotnetCli.Restore("--verbosity", "verbose", "--disable-parallel", "--infer-runtimes", "--fallbacksource", Dirs.Corehost)
dotnetCli.Restore(
"--verbosity", "verbose",
"--disable-parallel",
"--infer-runtimes",
"--fallbacksource", Dirs.Corehost)
.WorkingDirectory(SharedFrameworkSourceRoot)
.Execute()
.EnsureSuccessful();