Speedup build
This commit is contained in:
parent
88ffa548ba
commit
c3984443cd
3 changed files with 118 additions and 78 deletions
|
@ -87,18 +87,21 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
string currentRid = GetRuntimeId();
|
||||
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion");
|
||||
|
||||
PrepareDummyRuntimeNuGetPackage(
|
||||
DotNetCli.Stage0,
|
||||
buildVersion.HostNuGetPackageVersion,
|
||||
Dirs.CorehostDummyPackages);
|
||||
foreach (var hostPackageId in HostPackages)
|
||||
{
|
||||
foreach (var rid in HostPackageSupportedRids)
|
||||
{
|
||||
if (! rid.Equals(currentRid))
|
||||
if (!rid.Equals(currentRid))
|
||||
{
|
||||
CreateDummyRuntimeNuGetPackage(
|
||||
DotNetCli.Stage0,
|
||||
DotNetCli.Stage0,
|
||||
hostPackageId,
|
||||
rid,
|
||||
buildVersion.HostNuGetPackageVersion,
|
||||
rid,
|
||||
buildVersion.HostNuGetPackageVersion,
|
||||
Dirs.CorehostDummyPackages);
|
||||
}
|
||||
}
|
||||
|
@ -354,17 +357,14 @@ 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}";
|
||||
|
||||
private static void PrepareDummyRuntimeNuGetPackage(DotNetCli dotnet, string version, string outputDir)
|
||||
{
|
||||
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(" \"runtimes\": { \"win7-x64\": { } },");
|
||||
projectJson.Append("}");
|
||||
|
||||
var programCs = "using System; namespace ConsoleApplication { public class Program { public static void Main(string[] args) { Console.WriteLine(\"Hello World!\"); } } }";
|
||||
|
@ -384,11 +384,28 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
.WorkingDirectory(tempPjDirectory)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
|
||||
dotnet.Build(tempPjFile, "--runtime", rid)
|
||||
dotnet.Build(tempPjFile, "--runtime", "win7-x64")
|
||||
.WorkingDirectory(tempPjDirectory)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
}
|
||||
|
||||
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("}");
|
||||
|
||||
var tempPjDirectory = Path.Combine(Dirs.Intermediate, "dummyNuGetPackageIntermediate");
|
||||
var tempPjFile = Path.Combine(tempPjDirectory, "project.json");
|
||||
|
||||
File.WriteAllText(tempPjFile, projectJson.ToString());
|
||||
|
||||
dotnet.Pack(
|
||||
tempPjFile, "--no-build",
|
||||
|
|
|
@ -13,6 +13,17 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
public static class TestPackageProjects
|
||||
{
|
||||
public class TestPackageProject
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public bool IsTool { get; set; }
|
||||
public string Path { get; set; }
|
||||
public bool IsApplicable { get; set; }
|
||||
public string VersionSuffix { get; set; }
|
||||
public bool Clean { get; set; }
|
||||
public string[] Frameworks { get; set; }
|
||||
}
|
||||
|
||||
private static string s_testPackageBuildVersionSuffix = "<buildversion>";
|
||||
|
||||
public static string TestPackageBuildVersionSuffix
|
||||
|
@ -23,160 +34,177 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
}
|
||||
}
|
||||
|
||||
public static readonly dynamic[] Projects = new[]
|
||||
public static readonly TestPackageProject[] Projects = new[]
|
||||
{
|
||||
new
|
||||
new TestPackageProject()
|
||||
{
|
||||
Name = "PackageWithFakeNativeDep",
|
||||
IsTool = false,
|
||||
Path = "TestAssets/TestPackages/PackageWithFakeNativeDep",
|
||||
IsApplicable = new Func<bool>(() => true),
|
||||
IsApplicable = true,
|
||||
VersionSuffix = s_testPackageBuildVersionSuffix,
|
||||
Clean = true
|
||||
Clean = true,
|
||||
Frameworks = new [] { "net45" }
|
||||
},
|
||||
new
|
||||
new TestPackageProject()
|
||||
{
|
||||
Name = "dotnet-dependency-context-test",
|
||||
IsTool = true,
|
||||
Path = "TestAssets/TestPackages/dotnet-dependency-context-test",
|
||||
IsApplicable = new Func<bool>(() => true),
|
||||
IsApplicable = true,
|
||||
VersionSuffix = s_testPackageBuildVersionSuffix,
|
||||
Clean = true
|
||||
Clean = true,
|
||||
Frameworks = new [] { "netcoreapp1.0" }
|
||||
},
|
||||
new
|
||||
new TestPackageProject()
|
||||
{
|
||||
Name = "dotnet-dependency-tool-invoker",
|
||||
IsTool = true,
|
||||
Path = "TestAssets/TestPackages/dotnet-dependency-tool-invoker",
|
||||
IsApplicable = new Func<bool>(() => CurrentPlatform.IsWindows),
|
||||
IsApplicable = CurrentPlatform.IsWindows,
|
||||
VersionSuffix = s_testPackageBuildVersionSuffix,
|
||||
Clean = true
|
||||
Clean = true,
|
||||
Frameworks = new [] { "netcoreapp1.0" }
|
||||
},
|
||||
new
|
||||
new TestPackageProject()
|
||||
{
|
||||
Name = "dotnet-desktop-and-portable",
|
||||
IsTool = true,
|
||||
Path = "TestAssets/TestPackages/dotnet-desktop-and-portable",
|
||||
IsApplicable = new Func<bool>(() => CurrentPlatform.IsWindows),
|
||||
IsApplicable = CurrentPlatform.IsWindows,
|
||||
VersionSuffix = s_testPackageBuildVersionSuffix,
|
||||
Clean = true
|
||||
Clean = true,
|
||||
Frameworks = new [] { "net451", "netcoreapp1.0" }
|
||||
},
|
||||
new
|
||||
new TestPackageProject()
|
||||
{
|
||||
Name = "dotnet-hello",
|
||||
IsTool = true,
|
||||
Path = "TestAssets/TestPackages/dotnet-hello/v1/dotnet-hello",
|
||||
IsApplicable = new Func<bool>(() => true),
|
||||
IsApplicable =true,
|
||||
VersionSuffix = string.Empty,
|
||||
Clean = true
|
||||
Clean = true,
|
||||
Frameworks = new [] { "netcoreapp1.0" }
|
||||
},
|
||||
new
|
||||
new TestPackageProject()
|
||||
{
|
||||
Name = "dotnet-hello",
|
||||
IsTool = true,
|
||||
Path = "TestAssets/TestPackages/dotnet-hello/v2/dotnet-hello",
|
||||
IsApplicable = new Func<bool>(() => true),
|
||||
IsApplicable = true,
|
||||
VersionSuffix = string.Empty,
|
||||
Clean = true
|
||||
Clean = true,
|
||||
Frameworks = new [] { "netcoreapp1.0" }
|
||||
},
|
||||
new
|
||||
new TestPackageProject()
|
||||
{
|
||||
Name = "dotnet-portable",
|
||||
IsTool = true,
|
||||
Path = "TestAssets/TestPackages/dotnet-portable",
|
||||
IsApplicable = new Func<bool>(() => true),
|
||||
IsApplicable = true,
|
||||
VersionSuffix = string.Empty,
|
||||
Clean = true
|
||||
Clean = true,
|
||||
Frameworks = new [] { "netcoreapp1.0" }
|
||||
},
|
||||
new
|
||||
new TestPackageProject()
|
||||
{
|
||||
Name = "Microsoft.DotNet.Cli.Utils",
|
||||
IsTool = true,
|
||||
Path = "src/Microsoft.DotNet.Cli.Utils",
|
||||
IsApplicable = new Func<bool>(() => true),
|
||||
IsApplicable = true,
|
||||
VersionSuffix = s_testPackageBuildVersionSuffix,
|
||||
Clean = false
|
||||
Clean = false,
|
||||
Frameworks = new [] { "net451", "netstandard1.5" }
|
||||
},
|
||||
new
|
||||
new TestPackageProject()
|
||||
{
|
||||
Name = "Microsoft.DotNet.ProjectModel",
|
||||
IsTool = true,
|
||||
Path = "src/Microsoft.DotNet.ProjectModel",
|
||||
IsApplicable = new Func<bool>(() => true),
|
||||
IsApplicable = true,
|
||||
VersionSuffix = s_testPackageBuildVersionSuffix,
|
||||
Clean = false
|
||||
Clean = false,
|
||||
Frameworks = new [] { "net451", "netstandard1.5" }
|
||||
},
|
||||
new
|
||||
new TestPackageProject()
|
||||
{
|
||||
Name = "Microsoft.DotNet.ProjectModel.Loader",
|
||||
IsTool = true,
|
||||
Path = "src/Microsoft.DotNet.ProjectModel.Loader",
|
||||
IsApplicable = new Func<bool>(() => true),
|
||||
IsApplicable = true,
|
||||
VersionSuffix = s_testPackageBuildVersionSuffix,
|
||||
Clean = false
|
||||
Clean = false,
|
||||
Frameworks = new [] { "netstandard1.5" }
|
||||
},
|
||||
new
|
||||
new TestPackageProject()
|
||||
{
|
||||
Name = "Microsoft.DotNet.ProjectModel.Workspaces",
|
||||
IsTool = true,
|
||||
Path = "src/Microsoft.DotNet.ProjectModel.Workspaces",
|
||||
IsApplicable = new Func<bool>(() => true),
|
||||
IsApplicable =true,
|
||||
VersionSuffix = s_testPackageBuildVersionSuffix,
|
||||
Clean = false
|
||||
Clean = false,
|
||||
Frameworks = new [] { "netstandard1.5" }
|
||||
},
|
||||
new
|
||||
new TestPackageProject()
|
||||
{
|
||||
Name = "Microsoft.DotNet.InternalAbstractions",
|
||||
IsTool = true,
|
||||
Path = "src/Microsoft.DotNet.InternalAbstractions",
|
||||
IsApplicable = new Func<bool>(() => true),
|
||||
IsApplicable = true,
|
||||
VersionSuffix = s_testPackageBuildVersionSuffix,
|
||||
Clean = false
|
||||
Clean = false,
|
||||
Frameworks = new [] { "net451", "netstandard1.3" }
|
||||
},
|
||||
new
|
||||
new TestPackageProject()
|
||||
{
|
||||
Name = "Microsoft.Extensions.DependencyModel",
|
||||
IsTool = true,
|
||||
Path = "src/Microsoft.Extensions.DependencyModel",
|
||||
IsApplicable = new Func<bool>(() => true),
|
||||
IsApplicable = true,
|
||||
VersionSuffix = s_testPackageBuildVersionSuffix,
|
||||
Clean = false
|
||||
Clean = false,
|
||||
Frameworks = new [] { "net451", "netstandard1.5" }
|
||||
},
|
||||
new
|
||||
new TestPackageProject()
|
||||
{
|
||||
Name = "Microsoft.Extensions.Testing.Abstractions",
|
||||
IsTool = true,
|
||||
Path = "src/Microsoft.Extensions.Testing.Abstractions",
|
||||
IsApplicable = new Func<bool>(() => true),
|
||||
IsApplicable = true,
|
||||
VersionSuffix = s_testPackageBuildVersionSuffix,
|
||||
Clean = false
|
||||
Clean = false,
|
||||
Frameworks = new [] { "net451", "netstandard1.5" }
|
||||
},
|
||||
new
|
||||
new TestPackageProject()
|
||||
{
|
||||
Name = "Microsoft.DotNet.Compiler.Common",
|
||||
IsTool = true,
|
||||
Path = "src/Microsoft.DotNet.Compiler.Common",
|
||||
IsApplicable = new Func<bool>(() => true),
|
||||
IsApplicable = true,
|
||||
VersionSuffix = s_testPackageBuildVersionSuffix,
|
||||
Clean = false
|
||||
Clean = false,
|
||||
Frameworks = new [] { "netstandard1.5" }
|
||||
},
|
||||
new
|
||||
new TestPackageProject()
|
||||
{
|
||||
Name = "Microsoft.DotNet.Files",
|
||||
IsTool = true,
|
||||
Path = "src/Microsoft.DotNet.Files",
|
||||
IsApplicable = new Func<bool>(() => true),
|
||||
IsApplicable = true,
|
||||
VersionSuffix = s_testPackageBuildVersionSuffix,
|
||||
Clean = false
|
||||
Clean = false,
|
||||
Frameworks = new [] { "netstandard1.5" }
|
||||
},
|
||||
new
|
||||
new TestPackageProject()
|
||||
{
|
||||
Name = "dotnet-compile-fsc",
|
||||
IsTool = true,
|
||||
Path = "src/dotnet-compile-fsc",
|
||||
IsApplicable = new Func<bool>(() => true),
|
||||
IsApplicable = true,
|
||||
VersionSuffix = s_testPackageBuildVersionSuffix,
|
||||
Clean = true
|
||||
Clean = true,
|
||||
Frameworks = new [] { "netcoreapp1.0" }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
Rmdir(Dirs.TestPackages);
|
||||
Mkdirp(Dirs.TestPackages);
|
||||
|
||||
foreach (var testPackageProject in TestPackageProjects.Projects.Where(p => p.IsApplicable()))
|
||||
foreach (var testPackageProject in TestPackageProjects.Projects.Where(p => p.IsApplicable))
|
||||
{
|
||||
var relativePath = testPackageProject.Path;
|
||||
|
||||
|
@ -162,17 +162,11 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
var fullPath = Path.Combine(c.BuildContext.BuildDirectory, relativePath.Replace('/', Path.DirectorySeparatorChar));
|
||||
c.Info($"Packing: {fullPath}");
|
||||
|
||||
// build and ignore failure, so net451 fail on non-windows doesn't crash the build
|
||||
var packageBuildFrameworks = new List<string>()
|
||||
{
|
||||
"netstandard1.5",
|
||||
"netstandard1.3",
|
||||
"netcoreapp1.0"
|
||||
};
|
||||
var packageBuildFrameworks = testPackageProject.Frameworks.ToList();
|
||||
|
||||
if (CurrentPlatform.IsWindows)
|
||||
if (!CurrentPlatform.IsWindows)
|
||||
{
|
||||
packageBuildFrameworks.Add("net451");
|
||||
packageBuildFrameworks.RemoveAll(f => f.StartsWith("net4"));
|
||||
}
|
||||
|
||||
foreach (var packageBuildFramework in packageBuildFrameworks)
|
||||
|
@ -185,8 +179,9 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
buildArgs.Add(fullPath);
|
||||
|
||||
Mkdirp(Dirs.TestPackagesBuild);
|
||||
var packBuildResult = DotNetCli.Stage1.Build(buildArgs.ToArray())
|
||||
.Execute();
|
||||
dotnet.Build(buildArgs.ToArray())
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
}
|
||||
|
||||
var projectJson = Path.Combine(fullPath, "project.json");
|
||||
|
@ -225,7 +220,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
[Target]
|
||||
public static BuildTargetResult CleanTestPackages(BuildTargetContext c)
|
||||
{
|
||||
foreach (var packageProject in TestPackageProjects.Projects.Where(p => p.IsApplicable() && p.Clean))
|
||||
foreach (var packageProject in TestPackageProjects.Projects.Where(p => p.IsApplicable && p.Clean))
|
||||
{
|
||||
Rmdir(Path.Combine(Dirs.NuGetPackages, packageProject.Name));
|
||||
if(packageProject.IsTool)
|
||||
|
|
Loading…
Add table
Reference in a new issue