t Convert Test Assets to Microsoft.NETCore.App
fix dotnet-compile-fsc failures fix test failures
This commit is contained in:
parent
b682ab1d4f
commit
83d78129db
125 changed files with 483 additions and 492 deletions
|
@ -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();
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
[Target(nameof(RestoreTestAssetPackages), nameof(BuildTestAssetPackages))]
|
||||
public static BuildTargetResult SetupTestPackages(BuildTargetContext c) => c.Success();
|
||||
|
||||
[Target(nameof(RestoreTestAssetProjects), nameof(RestoreDesktopTestAssetProjects), nameof(RestoreCrossPublishTestAssetProjects), nameof(BuildTestAssetProjects))]
|
||||
[Target(nameof(RestoreTestAssetProjects), nameof(RestoreDesktopTestAssetProjects), nameof(BuildTestAssetProjects))]
|
||||
public static BuildTargetResult SetupTestProjects(BuildTargetContext c) => c.Success();
|
||||
|
||||
[Target]
|
||||
|
@ -70,7 +70,10 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
CleanNuGetTempCache();
|
||||
|
||||
var dotnet = DotNetCli.Stage2;
|
||||
dotnet.Restore("--verbosity", "verbose", "--infer-runtimes", "--fallbacksource", Dirs.Corehost)
|
||||
dotnet.Restore("--verbosity", "verbose",
|
||||
"--infer-runtimes",
|
||||
"--fallbacksource", Dirs.Corehost,
|
||||
"--fallbacksource", Dirs.CorehostDummyPackages)
|
||||
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestPackages"))
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
|
@ -91,25 +94,18 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
"--verbosity", "verbose",
|
||||
"--infer-runtimes",
|
||||
"--fallbacksource", Dirs.TestPackages,
|
||||
"--fallbacksource", Dirs.Corehost)
|
||||
"--fallbacksource", Dirs.Corehost,
|
||||
"--fallbacksource", Dirs.CorehostDummyPackages)
|
||||
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestProjects"))
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
|
||||
// The 'ProjectWithTests' is a portable test app. Cannot call --infer-runtimes on it, since on win x64 machines,
|
||||
// the x86 runtime is being inferred, and there are no x86 DotNetHost packages
|
||||
dotnet.Restore(
|
||||
"--verbosity", "verbose",
|
||||
"--fallbacksource", Dirs.Corehost)
|
||||
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "ProjectWithTests"))
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
|
||||
// The 'ProjectModelServer' directory contains intentionally-unresolved dependencies, so don't check for success. Also, suppress the output
|
||||
dotnet.Restore(
|
||||
"--verbosity", "verbose",
|
||||
"--infer-runtimes",
|
||||
"--fallbacksource", Dirs.Corehost)
|
||||
"--fallbacksource", Dirs.Corehost,
|
||||
"--fallbacksource", Dirs.CorehostDummyPackages)
|
||||
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "ProjectModelServer", "DthTestProjects"))
|
||||
.Execute();
|
||||
|
||||
|
@ -131,24 +127,13 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
dotnet.Restore("--verbosity", "verbose",
|
||||
"--infer-runtimes",
|
||||
"--fallbacksource", Dirs.TestPackages,
|
||||
"--fallbacksource", Dirs.Corehost)
|
||||
"--fallbacksource", Dirs.Corehost,
|
||||
"--fallbacksource", Dirs.CorehostDummyPackages)
|
||||
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "DesktopTestProjects"))
|
||||
.Execute().EnsureSuccessful();
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult RestoreCrossPublishTestAssetProjects(BuildTargetContext c)
|
||||
{
|
||||
var dotnet = DotNetCli.Stage2;
|
||||
|
||||
dotnet.Restore("--verbosity", "verbose")
|
||||
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "CrossPublishTestProjects"))
|
||||
.Execute().EnsureSuccessful();
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(CleanTestPackages), nameof(CleanProductPackages))]
|
||||
public static BuildTargetResult BuildTestAssetPackages(BuildTargetContext c)
|
||||
|
@ -178,7 +163,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
"netstandard1.5",
|
||||
"netstandard1.3",
|
||||
"netstandardapp1.5"
|
||||
"netcoreapp1.0"
|
||||
};
|
||||
|
||||
if (CurrentPlatform.IsWindows)
|
||||
|
@ -262,20 +247,12 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
foreach (var project in projects)
|
||||
{
|
||||
c.Info($"Building: {project}");
|
||||
dotnet.Build("--framework", "netstandardapp1.5")
|
||||
dotnet.Build("--framework", "netcoreapp1.0")
|
||||
.WorkingDirectory(Path.GetDirectoryName(project))
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
}
|
||||
|
||||
// build ProjectWithTests, which is outside of TestProjects and targets netcoreapp
|
||||
string projectWithTests = Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "ProjectWithTests");
|
||||
c.Info($"Building: {projectWithTests}");
|
||||
dotnet.Build("--framework", "netcoreapp1.0")
|
||||
.WorkingDirectory(projectWithTests)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
|
@ -288,7 +265,8 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
CleanNuGetTempCache();
|
||||
DotNetCli.Stage2.Restore("--verbosity", "verbose",
|
||||
"--fallbacksource", Dirs.TestPackages,
|
||||
"--fallbacksource", Dirs.Corehost)
|
||||
"--fallbacksource", Dirs.Corehost,
|
||||
"--fallbacksource", Dirs.CorehostDummyPackages)
|
||||
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "test"))
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
public string VersionSuffix => $"{ReleaseSuffix}-{CommitCountString}";
|
||||
public string NuGetVersion => $"{Major}.{Minor}.{Patch}-{VersionSuffix}";
|
||||
public string NetCoreAppVersion => $"{Major}.{Minor}.{Patch}-rc2-3{CommitCountString}";
|
||||
public string HostNuGetPackageVersion => $"{Major}.{Minor}.1-rc2-{CommitCountString}-00";
|
||||
public string ProductionVersion => $"{Major}.{Minor}.{Patch}";
|
||||
|
||||
public string GenerateMsiVersion()
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
public static readonly string Stage2Compilation = Path.Combine(Output, "stage2compilation");
|
||||
public static readonly string Stage2Symbols = Path.Combine(Output, "stage2symbols");
|
||||
public static readonly string Corehost = Path.Combine(Output, "corehost");
|
||||
public static readonly string CorehostDummyPackages = Path.Combine(Output, "corehostdummypackages");
|
||||
public static readonly string TestOutput = Path.Combine(Output, "tests");
|
||||
public static readonly string TestArtifacts = Path.Combine(TestOutput, "artifacts");
|
||||
public static readonly string TestPackages = Path.Combine(TestOutput, "packages");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue