Skip to content

Commit 7d6b26d

Browse files
Fadi Hannanguerrera
authored andcommitted
Crossgen Task (#2997)
* Intitial implementation of the crossgen task, and plumbing in the SDK targets to invoke the task. Added new condition to download runtime packs: when the ReadyToRun property is set. Adding R2R exclusion list capability * Making the crossgen task a ToolTask based task (and necessary refactoring to have a ToolTaskBase) Fixing logic with RuntimeIdentifier values used by the task (now it's read from the RuntimePack) * Exclude ref assemblies from compilation based on the presence of a ReferenceAssemblyAttribute * Rewriting some of the logic around host/target platform compatibility validation to use the runtime graph data * Split R2R compilation task into two tasks, to not have a single task that calls ExecuteTool multiple times. The split also enables msbuild to automatically skip entries that are already up to date. Removed ToolTaskBase since it's not really adding much value * Using NETCoreSdkRuntimeIdentifier to read host machine's RID * Adding crossgen CI tests * CR feedback * Resolve merge conflicts
1 parent 701abd1 commit 7d6b26d

24 files changed

+1258
-69
lines changed

src/Tasks/Common/LogAdapter.cs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Copyright (c) .NET Foundation and contributors. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
using Microsoft.Build.Utilities;
6+
7+
namespace Microsoft.NET.Build.Tasks
8+
{
9+
internal sealed class LogAdapter : Logger
10+
{
11+
private TaskLoggingHelper _taskLogger;
12+
13+
public LogAdapter(TaskLoggingHelper taskLogger)
14+
{
15+
_taskLogger = taskLogger;
16+
}
17+
18+
protected override void LogCore(in Message message)
19+
{
20+
switch (message.Level)
21+
{
22+
case MessageLevel.Error:
23+
_taskLogger.LogError(
24+
subcategory: default,
25+
errorCode: message.Code,
26+
helpKeyword: default,
27+
file: message.File,
28+
lineNumber: default,
29+
columnNumber: default,
30+
endLineNumber: default,
31+
endColumnNumber: default,
32+
message: message.Text);
33+
break;
34+
35+
case MessageLevel.Warning:
36+
_taskLogger.LogWarning(
37+
subcategory: default,
38+
warningCode: message.Code,
39+
helpKeyword: default,
40+
file: message.File,
41+
lineNumber: default,
42+
columnNumber: default,
43+
endLineNumber: default,
44+
endColumnNumber: default,
45+
message: message.Text);
46+
break;
47+
48+
case MessageLevel.HighImportance:
49+
case MessageLevel.NormalImportance:
50+
case MessageLevel.LowImportance:
51+
_taskLogger.LogMessage(
52+
subcategory: default,
53+
code: message.Code,
54+
helpKeyword: default,
55+
file: message.File,
56+
lineNumber: default,
57+
columnNumber: default,
58+
endLineNumber: default,
59+
endColumnNumber: default,
60+
importance: message.Level.ToImportance(),
61+
message: message.Text);
62+
break;
63+
64+
default:
65+
throw new ArgumentException(
66+
$"Message \"{message.Code}: {message.Text}\" logged with invalid Level=${message.Level}",
67+
paramName: nameof(message));
68+
}
69+
}
70+
}
71+
}

src/Tasks/Common/MetadataKeys.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ internal static class MetadataKeys
8080
public const string CopyToOutput = "CopyToOutput";
8181
public const string BuildAction = "BuildAction";
8282
public const string OutputPath = "OutputPath";
83+
public const string CopyToPublishDirectory = "CopyToPublishDirectory";
8384

8485
// Resource assemblies
8586
public const string Culture = "Culture";

src/Tasks/Common/Resources/Strings.resx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,4 +493,16 @@ The following are names of parameters or literal values and should not be transl
493493
<value>NETSDK1093: NETSDK1093: Project tools (DotnetCliTool) only support targeting .NET Core 2.2 and lower.</value>
494494
<comment>{StrBegin="NETSDK1093: "}</comment>
495495
</data>
496+
<data name="ReadyToRunNoValidRuntimePackageError" xml:space="preserve">
497+
<value>NETSDK1094: Unable to optimize assemblies for performance: a valid runtime package was not found. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</value>
498+
<comment>{StrBegin="NETSDK1094: "}</comment>
499+
</data>
500+
<data name="ReadyToRunTargetNotSuppotedError" xml:space="preserve">
501+
<value>NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</value>
502+
<comment>{StrBegin="NETSDK1095: "}</comment>
503+
</data>
504+
<data name="ReadyToRunCompilationFailed" xml:space="preserve">
505+
<value>NETSDK1096: Optimizing assemblies for performance failed. You can either exclude the failing assemblies from being optimized, or set the ReadyToRun property to false.</value>
506+
<comment>{StrBegin="NETSDK1096: "}</comment>
507+
</data>
496508
</root>

src/Tasks/Common/Resources/xlf/Strings.cs.xlf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,21 @@ The following are names of parameters or literal values and should not be transl
396396
<target state="new">NETSDK1093: NETSDK1093: Project tools (DotnetCliTool) only support targeting .NET Core 2.2 and lower.</target>
397397
<note>{StrBegin="NETSDK1093: "}</note>
398398
</trans-unit>
399+
<trans-unit id="ReadyToRunCompilationFailed">
400+
<source>NETSDK1096: Optimizing assemblies for performance failed. You can either exclude the failing assemblies from being optimized, or set the ReadyToRun property to false.</source>
401+
<target state="new">NETSDK1096: Optimizing assemblies for performance failed. You can either exclude the failing assemblies from being optimized, or set the ReadyToRun property to false.</target>
402+
<note>{StrBegin="NETSDK1096: "}</note>
403+
</trans-unit>
404+
<trans-unit id="ReadyToRunNoValidRuntimePackageError">
405+
<source>NETSDK1094: Unable to optimize assemblies for performance: a valid runtime package was not found. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</source>
406+
<target state="new">NETSDK1094: Unable to optimize assemblies for performance: a valid runtime package was not found. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</target>
407+
<note>{StrBegin="NETSDK1094: "}</note>
408+
</trans-unit>
409+
<trans-unit id="ReadyToRunTargetNotSuppotedError">
410+
<source>NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</source>
411+
<target state="new">NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</target>
412+
<note>{StrBegin="NETSDK1095: "}</note>
413+
</trans-unit>
399414
<trans-unit id="RuntimeIdentifierNotRecognized">
400415
<source>NETSDK1083: The specified RuntimeIdentifier '{0}' is not recognized.</source>
401416
<target state="translated">NETSDK1083: Zadaný RuntimeIdentifier {0} nejde rozpoznat.</target>

src/Tasks/Common/Resources/xlf/Strings.de.xlf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,21 @@ The following are names of parameters or literal values and should not be transl
396396
<target state="new">NETSDK1093: NETSDK1093: Project tools (DotnetCliTool) only support targeting .NET Core 2.2 and lower.</target>
397397
<note>{StrBegin="NETSDK1093: "}</note>
398398
</trans-unit>
399+
<trans-unit id="ReadyToRunCompilationFailed">
400+
<source>NETSDK1096: Optimizing assemblies for performance failed. You can either exclude the failing assemblies from being optimized, or set the ReadyToRun property to false.</source>
401+
<target state="new">NETSDK1096: Optimizing assemblies for performance failed. You can either exclude the failing assemblies from being optimized, or set the ReadyToRun property to false.</target>
402+
<note>{StrBegin="NETSDK1096: "}</note>
403+
</trans-unit>
404+
<trans-unit id="ReadyToRunNoValidRuntimePackageError">
405+
<source>NETSDK1094: Unable to optimize assemblies for performance: a valid runtime package was not found. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</source>
406+
<target state="new">NETSDK1094: Unable to optimize assemblies for performance: a valid runtime package was not found. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</target>
407+
<note>{StrBegin="NETSDK1094: "}</note>
408+
</trans-unit>
409+
<trans-unit id="ReadyToRunTargetNotSuppotedError">
410+
<source>NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</source>
411+
<target state="new">NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</target>
412+
<note>{StrBegin="NETSDK1095: "}</note>
413+
</trans-unit>
399414
<trans-unit id="RuntimeIdentifierNotRecognized">
400415
<source>NETSDK1083: The specified RuntimeIdentifier '{0}' is not recognized.</source>
401416
<target state="translated">NETSDK1083: Der angegebene RuntimeIdentifier "{0}" wird nicht erkannt.</target>

src/Tasks/Common/Resources/xlf/Strings.es.xlf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,21 @@ The following are names of parameters or literal values and should not be transl
396396
<target state="new">NETSDK1093: NETSDK1093: Project tools (DotnetCliTool) only support targeting .NET Core 2.2 and lower.</target>
397397
<note>{StrBegin="NETSDK1093: "}</note>
398398
</trans-unit>
399+
<trans-unit id="ReadyToRunCompilationFailed">
400+
<source>NETSDK1096: Optimizing assemblies for performance failed. You can either exclude the failing assemblies from being optimized, or set the ReadyToRun property to false.</source>
401+
<target state="new">NETSDK1096: Optimizing assemblies for performance failed. You can either exclude the failing assemblies from being optimized, or set the ReadyToRun property to false.</target>
402+
<note>{StrBegin="NETSDK1096: "}</note>
403+
</trans-unit>
404+
<trans-unit id="ReadyToRunNoValidRuntimePackageError">
405+
<source>NETSDK1094: Unable to optimize assemblies for performance: a valid runtime package was not found. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</source>
406+
<target state="new">NETSDK1094: Unable to optimize assemblies for performance: a valid runtime package was not found. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</target>
407+
<note>{StrBegin="NETSDK1094: "}</note>
408+
</trans-unit>
409+
<trans-unit id="ReadyToRunTargetNotSuppotedError">
410+
<source>NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</source>
411+
<target state="new">NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</target>
412+
<note>{StrBegin="NETSDK1095: "}</note>
413+
</trans-unit>
399414
<trans-unit id="RuntimeIdentifierNotRecognized">
400415
<source>NETSDK1083: The specified RuntimeIdentifier '{0}' is not recognized.</source>
401416
<target state="translated">NETSDK1083: El RuntimeIdentifier especificado "{0}" no se reconoce.</target>

src/Tasks/Common/Resources/xlf/Strings.fr.xlf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,21 @@ The following are names of parameters or literal values and should not be transl
396396
<target state="new">NETSDK1093: NETSDK1093: Project tools (DotnetCliTool) only support targeting .NET Core 2.2 and lower.</target>
397397
<note>{StrBegin="NETSDK1093: "}</note>
398398
</trans-unit>
399+
<trans-unit id="ReadyToRunCompilationFailed">
400+
<source>NETSDK1096: Optimizing assemblies for performance failed. You can either exclude the failing assemblies from being optimized, or set the ReadyToRun property to false.</source>
401+
<target state="new">NETSDK1096: Optimizing assemblies for performance failed. You can either exclude the failing assemblies from being optimized, or set the ReadyToRun property to false.</target>
402+
<note>{StrBegin="NETSDK1096: "}</note>
403+
</trans-unit>
404+
<trans-unit id="ReadyToRunNoValidRuntimePackageError">
405+
<source>NETSDK1094: Unable to optimize assemblies for performance: a valid runtime package was not found. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</source>
406+
<target state="new">NETSDK1094: Unable to optimize assemblies for performance: a valid runtime package was not found. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</target>
407+
<note>{StrBegin="NETSDK1094: "}</note>
408+
</trans-unit>
409+
<trans-unit id="ReadyToRunTargetNotSuppotedError">
410+
<source>NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</source>
411+
<target state="new">NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</target>
412+
<note>{StrBegin="NETSDK1095: "}</note>
413+
</trans-unit>
399414
<trans-unit id="RuntimeIdentifierNotRecognized">
400415
<source>NETSDK1083: The specified RuntimeIdentifier '{0}' is not recognized.</source>
401416
<target state="translated">NETSDK1083 : Le RuntimeIdentifier '{0}' spécifié n'est pas reconnu.</target>

src/Tasks/Common/Resources/xlf/Strings.it.xlf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,21 @@ The following are names of parameters or literal values and should not be transl
396396
<target state="new">NETSDK1093: NETSDK1093: Project tools (DotnetCliTool) only support targeting .NET Core 2.2 and lower.</target>
397397
<note>{StrBegin="NETSDK1093: "}</note>
398398
</trans-unit>
399+
<trans-unit id="ReadyToRunCompilationFailed">
400+
<source>NETSDK1096: Optimizing assemblies for performance failed. You can either exclude the failing assemblies from being optimized, or set the ReadyToRun property to false.</source>
401+
<target state="new">NETSDK1096: Optimizing assemblies for performance failed. You can either exclude the failing assemblies from being optimized, or set the ReadyToRun property to false.</target>
402+
<note>{StrBegin="NETSDK1096: "}</note>
403+
</trans-unit>
404+
<trans-unit id="ReadyToRunNoValidRuntimePackageError">
405+
<source>NETSDK1094: Unable to optimize assemblies for performance: a valid runtime package was not found. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</source>
406+
<target state="new">NETSDK1094: Unable to optimize assemblies for performance: a valid runtime package was not found. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</target>
407+
<note>{StrBegin="NETSDK1094: "}</note>
408+
</trans-unit>
409+
<trans-unit id="ReadyToRunTargetNotSuppotedError">
410+
<source>NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</source>
411+
<target state="new">NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</target>
412+
<note>{StrBegin="NETSDK1095: "}</note>
413+
</trans-unit>
399414
<trans-unit id="RuntimeIdentifierNotRecognized">
400415
<source>NETSDK1083: The specified RuntimeIdentifier '{0}' is not recognized.</source>
401416
<target state="translated">NETSDK1083: l'elemento RuntimeIdentifier '{0}' specificato non è riconosciuto.</target>

src/Tasks/Common/Resources/xlf/Strings.ja.xlf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,21 @@ The following are names of parameters or literal values and should not be transl
396396
<target state="new">NETSDK1093: NETSDK1093: Project tools (DotnetCliTool) only support targeting .NET Core 2.2 and lower.</target>
397397
<note>{StrBegin="NETSDK1093: "}</note>
398398
</trans-unit>
399+
<trans-unit id="ReadyToRunCompilationFailed">
400+
<source>NETSDK1096: Optimizing assemblies for performance failed. You can either exclude the failing assemblies from being optimized, or set the ReadyToRun property to false.</source>
401+
<target state="new">NETSDK1096: Optimizing assemblies for performance failed. You can either exclude the failing assemblies from being optimized, or set the ReadyToRun property to false.</target>
402+
<note>{StrBegin="NETSDK1096: "}</note>
403+
</trans-unit>
404+
<trans-unit id="ReadyToRunNoValidRuntimePackageError">
405+
<source>NETSDK1094: Unable to optimize assemblies for performance: a valid runtime package was not found. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</source>
406+
<target state="new">NETSDK1094: Unable to optimize assemblies for performance: a valid runtime package was not found. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</target>
407+
<note>{StrBegin="NETSDK1094: "}</note>
408+
</trans-unit>
409+
<trans-unit id="ReadyToRunTargetNotSuppotedError">
410+
<source>NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</source>
411+
<target state="new">NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. Either set the ReadyToRun property to false, or use a supported runtime identifier when publishing.</target>
412+
<note>{StrBegin="NETSDK1095: "}</note>
413+
</trans-unit>
399414
<trans-unit id="RuntimeIdentifierNotRecognized">
400415
<source>NETSDK1083: The specified RuntimeIdentifier '{0}' is not recognized.</source>
401416
<target state="translated">NETSDK1083: 指定された RuntimeIdentifier '{0}' を認識できません。</target>

0 commit comments

Comments
 (0)