Make publish do less work
- Added a runtime switch to build and compile - Flow the runtime from publish through build and compile
This commit is contained in:
parent
4e365921f7
commit
b16ecff0e9
6 changed files with 48 additions and 48 deletions
|
@ -23,6 +23,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
|||
|
||||
public static void MakeCompilationOutputRunnable(this ProjectContext context, string outputPath, string configuration)
|
||||
{
|
||||
// REVIEW: This shouldn't be copied on compile
|
||||
context
|
||||
.ProjectFile
|
||||
.Files
|
||||
|
@ -34,10 +35,15 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
|||
|
||||
if (context.TargetFramework.IsDesktop())
|
||||
{
|
||||
// On full framework, copy all dependencies to the output path
|
||||
exporter
|
||||
.GetDependencies()
|
||||
.SelectMany(e => e.RuntimeAssets())
|
||||
.CopyTo(outputPath);
|
||||
|
||||
// Generate binding redirects
|
||||
var outputName = context.GetOutputPathCalculator(outputPath).GetAssemblyPath(configuration);
|
||||
context.GenerateBindingRedirects(exporter, outputName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -45,10 +51,12 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
|||
.GetDependencies(LibraryType.Package)
|
||||
.WriteDepsTo(Path.Combine(outputPath, context.ProjectFile.Name + FileNameSuffixes.Deps));
|
||||
|
||||
// On core clr, only copy project references
|
||||
exporter.GetDependencies(LibraryType.Project)
|
||||
.SelectMany(e => e.RuntimeAssets())
|
||||
.CopyTo(outputPath);
|
||||
|
||||
// TODO: Pick a host based on the RID
|
||||
CoreHost.CopyTo(outputPath, context.ProjectFile.Name + Constants.ExeSuffix);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -274,15 +274,17 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
|
||||
args.Add("--framework");
|
||||
args.Add($"{projectDependency.Framework}");
|
||||
|
||||
if (!string.IsNullOrEmpty(_args.RuntimeValue))
|
||||
{
|
||||
args.Add("--runtime");
|
||||
args.Add(_args.RuntimeValue);
|
||||
}
|
||||
|
||||
args.Add("--configuration");
|
||||
args.Add(_args.ConfigValue);
|
||||
args.Add(projectDependency.Project.ProjectDirectory);
|
||||
|
||||
if (_args.NoHostValue)
|
||||
{
|
||||
args.Add("--no-host");
|
||||
}
|
||||
|
||||
var compileResult = Command.Create("dotnet-compile", args)
|
||||
.ForwardStdOut()
|
||||
.ForwardStdErr()
|
||||
|
@ -297,6 +299,11 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
var args = new List<string>();
|
||||
args.Add("--framework");
|
||||
args.Add(_rootProject.TargetFramework.ToString());
|
||||
if (!string.IsNullOrEmpty(_args.RuntimeValue))
|
||||
{
|
||||
args.Add("--runtime");
|
||||
args.Add(_args.RuntimeValue);
|
||||
}
|
||||
args.Add("--configuration");
|
||||
args.Add(_args.ConfigValue);
|
||||
args.Add("--output");
|
||||
|
@ -304,11 +311,6 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
args.Add("--temp-output");
|
||||
args.Add(_args.IntermediateValue);
|
||||
|
||||
if (_args.NoHostValue)
|
||||
{
|
||||
args.Add("--no-host");
|
||||
}
|
||||
|
||||
//native args
|
||||
if (_args.IsNativeValue)
|
||||
{
|
||||
|
|
|
@ -23,8 +23,8 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
private CommandOption _outputOption;
|
||||
private CommandOption _intermediateOutputOption;
|
||||
private CommandOption _frameworkOption;
|
||||
private CommandOption _runtimeOption;
|
||||
private CommandOption _configurationOption;
|
||||
private CommandOption _noHostOption;
|
||||
private CommandArgument _projectArgument;
|
||||
private CommandOption _nativeOption;
|
||||
private CommandOption _archOption;
|
||||
|
@ -39,8 +39,8 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
public string ProjectPathValue { get; set; }
|
||||
public string OutputValue { get; set; }
|
||||
public string IntermediateValue { get; set; }
|
||||
public string RuntimeValue{ get; set; }
|
||||
public string ConfigValue { get; set; }
|
||||
public bool NoHostValue { get; set; }
|
||||
public bool IsNativeValue { get; set; }
|
||||
public string ArchValue { get; set; }
|
||||
public string IlcArgsValue { get; set; }
|
||||
|
@ -75,7 +75,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
_intermediateOutputOption = _app.Option("-t|--temp-output <OUTPUT_DIR>", "Directory in which to place temporary outputs", CommandOptionType.SingleValue);
|
||||
_frameworkOption = _app.Option("-f|--framework <FRAMEWORK>", "Compile a specific framework", CommandOptionType.MultipleValue);
|
||||
_configurationOption = _app.Option("-c|--configuration <CONFIGURATION>", "Configuration under which to build", CommandOptionType.SingleValue);
|
||||
_noHostOption = _app.Option("--no-host", "Set this to skip publishing a runtime host when building for CoreCLR", CommandOptionType.NoValue);
|
||||
_runtimeOption = _app.Option("-r|--runtime <RUNTIME_IDENTIFIER>", "Target runtime to publish for", CommandOptionType.SingleValue);
|
||||
_projectArgument = _app.Argument("<PROJECT>", "The project to compile, defaults to the current directory. Can be a path to a project.json or a project directory");
|
||||
|
||||
// Native Args
|
||||
|
@ -103,7 +103,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
OutputValue = _outputOption.Value();
|
||||
IntermediateValue = _intermediateOutputOption.Value();
|
||||
ConfigValue = _configurationOption.Value() ?? Constants.DefaultConfiguration;
|
||||
NoHostValue = _noHostOption.HasValue();
|
||||
RuntimeValue = _runtimeOption.Value();
|
||||
|
||||
IsNativeValue = _nativeOption.HasValue();
|
||||
ArchValue = _archOption.Value();
|
||||
|
|
|
@ -10,9 +10,7 @@ using Microsoft.DotNet.Cli.Compiler.Common;
|
|||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using Microsoft.DotNet.ProjectModel.Compilation;
|
||||
using Microsoft.DotNet.ProjectModel.Graph;
|
||||
using Microsoft.DotNet.ProjectModel.Utilities;
|
||||
using NuGet.Frameworks;
|
||||
using Microsoft.Extensions.DependencyModel;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
|
@ -318,35 +316,28 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
success &= GenerateCultureResourceAssemblies(context.ProjectFile, dependencies, outputPath);
|
||||
}
|
||||
|
||||
bool generateBindingRedirects = false;
|
||||
if (success && !args.NoHostValue && compilationOptions.EmitEntryPoint.GetValueOrDefault())
|
||||
if (success)
|
||||
{
|
||||
generateBindingRedirects = true;
|
||||
var rids = PlatformServices.Default.Runtime.GetAllCandidateRuntimeIdentifiers();
|
||||
var runtimeContext = ProjectContext.Create(context.ProjectDirectory, context.TargetFramework, rids);
|
||||
runtimeContext
|
||||
.MakeCompilationOutputRunnable(outputPath, args.ConfigValue);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(context.ProjectFile.TestRunner))
|
||||
{
|
||||
generateBindingRedirects = true;
|
||||
var projectContext =
|
||||
ProjectContext.Create(context.ProjectDirectory, context.TargetFramework,
|
||||
new[] { PlatformServices.Default.Runtime.GetLegacyRestoreRuntimeIdentifier() });
|
||||
// TODO: Make this opt in via another mechanism
|
||||
var makeRunnable = compilationOptions.EmitEntryPoint.GetValueOrDefault() ||
|
||||
!string.IsNullOrEmpty(context.ProjectFile.TestRunner);
|
||||
|
||||
// Don't generate a deps file if we're on desktop
|
||||
if (!context.TargetFramework.IsDesktop())
|
||||
if (makeRunnable)
|
||||
{
|
||||
projectContext
|
||||
.CreateExporter(args.ConfigValue)
|
||||
.GetDependencies(LibraryType.Package)
|
||||
.WriteDepsTo(Path.Combine(outputPath, projectContext.ProjectFile.Name + FileNameSuffixes.Deps));
|
||||
}
|
||||
}
|
||||
var rids = new List<string>();
|
||||
if (string.IsNullOrEmpty(args.RuntimeValue))
|
||||
{
|
||||
rids.AddRange(PlatformServices.Default.Runtime.GetAllCandidateRuntimeIdentifiers());
|
||||
}
|
||||
else
|
||||
{
|
||||
rids.Add(args.RuntimeValue);
|
||||
}
|
||||
|
||||
if (generateBindingRedirects && context.TargetFramework.IsDesktop())
|
||||
{
|
||||
context.GenerateBindingRedirects(exporter, outputName);
|
||||
var runtimeContext = ProjectContext.Create(context.ProjectDirectory, context.TargetFramework, rids);
|
||||
runtimeContext
|
||||
.MakeCompilationOutputRunnable(outputPath, args.ConfigValue);
|
||||
}
|
||||
}
|
||||
|
||||
return PrintSummary(diagnostics, sw, success);
|
||||
|
|
|
@ -3,10 +3,8 @@
|
|||
|
||||
using Microsoft.Dnx.Runtime.Common.CommandLine;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Publish
|
||||
{
|
||||
|
|
|
@ -109,10 +109,11 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
new string[] {
|
||||
"--framework",
|
||||
$"{context.TargetFramework.DotNetFrameworkName}",
|
||||
"--runtime",
|
||||
context.RuntimeIdentifier,
|
||||
"--configuration",
|
||||
$"{configuration}",
|
||||
"--no-host",
|
||||
$"{context.ProjectFile.ProjectDirectory}"
|
||||
configuration,
|
||||
context.ProjectFile.ProjectDirectory
|
||||
})
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
|
|
Loading…
Reference in a new issue