diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/RunReadyToRunCompiler.cs b/src/Tasks/Microsoft.NET.Build.Tasks/RunReadyToRunCompiler.cs index e7a36b556429..e35ead24aece 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/RunReadyToRunCompiler.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/RunReadyToRunCompiler.cs @@ -23,6 +23,7 @@ public class RunReadyToRunCompiler : ToolTask public bool ShowCompilerWarnings { get; set; } public bool UseCrossgen2 { get; set; } public string Crossgen2ExtraCommandLineArgs { get; set; } + public string Crossgen2CompositeExtraCommandLineArgs { get; set; } public ITaskItem[] Crossgen2PgoFiles { get; set; } public string Crossgen2ContainerFormat { get; set; } @@ -362,6 +363,17 @@ private string GenerateCrossgen2ResponseFile() } } + // Arguments that are only valid for full composite builds (e.g. --strip-il-bodies). + // These arguments will not be applied to any assemblies that have been excluded from the composite image. + if (_createCompositeImage && !_partialCompile + && !string.IsNullOrEmpty(Crossgen2CompositeExtraCommandLineArgs)) + { + foreach (string extraArg in Crossgen2CompositeExtraCommandLineArgs.Split([';'], StringSplitOptions.RemoveEmptyEntries)) + { + result.AppendLine(extraArg); + } + } + if (_partialCompile) { result.AppendLine("--partial"); diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets index 8e39f25b7cd1..a216e8010ea8 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets @@ -46,6 +46,12 @@ Copyright (c) .NET Foundation. All rights reserved. $(PublishReadyToRunCrossgen2ExtraArgs);--strip-debug-info $(PublishReadyToRunCrossgen2ExtraArgs);--strip-debug-info $(PublishReadyToRunCrossgen2ExtraArgs);--strip-debug-info + + $(PublishReadyToRunCrossgen2CompositeExtraArgs);--strip-il-bodies + $(PublishReadyToRunCrossgen2CompositeExtraArgs);--strip-il-bodies + $(PublishReadyToRunCrossgen2CompositeExtraArgs);--strip-il-bodies + $(PublishReadyToRunCrossgen2CompositeExtraArgs);--strip-il-bodies + $(PublishReadyToRunCrossgen2CompositeExtraArgs);--strip-il-bodies @@ -505,6 +511,7 @@ Copyright (c) .NET Foundation. All rights reserved. Crossgen2PgoFiles="@(_ReadyToRunPgoFiles)" Crossgen2ContainerFormat="$(PublishReadyToRunContainerFormat)" Crossgen2ExtraCommandLineArgs="$(PublishReadyToRunCrossgen2ExtraArgs)" + Crossgen2CompositeExtraCommandLineArgs="$(PublishReadyToRunCrossgen2CompositeExtraArgs)" ImplementationAssemblyReferences="@(_ReadyToRunAssembliesToReference)" ShowCompilerWarnings="$(PublishReadyToRunShowWarnings)" CompilationEntry="@(_ReadyToRunCompileList)"