More build cleanup and tweaks
- Added generic Get<T> to build context
This commit is contained in:
parent
078d6a8d5f
commit
c7e9139fa6
4 changed files with 17 additions and 15 deletions
|
@ -33,6 +33,8 @@ namespace Microsoft.DotNet.Cli.Build.Framework
|
|||
_maxTargetLen = targets.Values.Select(t => t.Name.Length).Max();
|
||||
}
|
||||
|
||||
public T Get<T>(string name) => (T)this[name];
|
||||
|
||||
public BuildTargetResult RunTarget(string name) => RunTarget(name, force: false);
|
||||
|
||||
public BuildTargetResult RunTarget(string name, bool force)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.FS;
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
@ -63,7 +63,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
Rmdir(cmakeOut);
|
||||
Mkdirp(cmakeOut);
|
||||
|
||||
var configuration = (string)c.BuildContext["Configuration"];
|
||||
var configuration = c.BuildContext.Get<string>("Configuration");
|
||||
|
||||
// Run the build
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
|
@ -120,7 +120,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
[Target]
|
||||
public static BuildTargetResult CompileStage2(BuildTargetContext c)
|
||||
{
|
||||
var configuration = (string)c.BuildContext["Configuration"];
|
||||
var configuration = c.BuildContext.Get<string>("Configuration");
|
||||
|
||||
CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src"));
|
||||
CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "test"));
|
||||
|
@ -161,7 +161,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
dotnet.SetDotNetHome();
|
||||
|
||||
var configuration = (string)c.BuildContext["Configuration"];
|
||||
var configuration = c.BuildContext.Get<string>("Configuration");
|
||||
var binDir = Path.Combine(outputDir, "bin");
|
||||
var runtimeOutputDir = Path.Combine(outputDir, "runtime", "coreclr");
|
||||
|
||||
|
@ -241,7 +241,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
}
|
||||
|
||||
// Generate .version file
|
||||
var version = ((BuildVersion)c.BuildContext["BuildVersion"]).SimpleVersion;
|
||||
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
|
||||
var content = $@"{c.BuildContext["CommitHash"]}{Environment.NewLine}{version}{Environment.NewLine}";
|
||||
File.WriteAllText(Path.Combine(outputDir, ".version"), content);
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
|
@ -19,7 +19,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
// Set up the environment variables previously defined by common.sh/ps1
|
||||
// This is overkill, but I want to cover all the variables used in all OSes (including where some have the same names)
|
||||
var buildVersion = (BuildVersion)c.BuildContext["BuildVersion"];
|
||||
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion");
|
||||
var env = new Dictionary<string, string>()
|
||||
{
|
||||
{ "RID", PlatformServices.Default.Runtime.GetRuntimeIdentifier() },
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.FS;
|
||||
using static Microsoft.DotNet.Cli.Build.Utils;
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
using static Microsoft.DotNet.Cli.Build.Utils;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
|
@ -180,7 +180,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
[Target]
|
||||
public static BuildTargetResult ValidateDependencies(BuildTargetContext c)
|
||||
{
|
||||
var configuration = (string)c.BuildContext["Configuration"];
|
||||
var configuration = c.BuildContext.Get<string>("Configuration");
|
||||
var dotnet = DotNetCli.Stage2;
|
||||
|
||||
c.Info("Publishing MultiProjectValidator");
|
||||
|
|
Loading…
Add table
Reference in a new issue