@@ -43,18 +43,6 @@ public class ProcessFrameworkReferences : TaskBase
43
43
44
44
public bool RequiresILLinkPack { get ; set ; }
45
45
46
- public bool IsAotCompatible { get ; set ; }
47
-
48
- public bool EnableAotAnalyzer { get ; set ; }
49
-
50
- public bool PublishTrimmed { get ; set ; }
51
-
52
- public bool IsTrimmable { get ; set ; }
53
-
54
- public bool EnableTrimAnalyzer { get ; set ; }
55
-
56
- public bool EnableSingleFileAnalyzer { get ; set ; }
57
-
58
46
public bool AotUseKnownRuntimePackForTarget { get ; set ; }
59
47
60
48
public string RuntimeIdentifier { get ; set ; }
@@ -128,6 +116,10 @@ public class ProcessFrameworkReferences : TaskBase
128
116
[ Output ]
129
117
public ITaskItem [ ] UnavailableRuntimePacks { get ; set ; }
130
118
119
+ // Tool packs which aren't available for the specified TargetFramework/RuntimeIdentifier
120
+ [ Output ]
121
+ public ITaskItem [ ] UnavailableToolPacks { get ; set ; }
122
+
131
123
[ Output ]
132
124
public string [ ] KnownRuntimeIdentifierPlatforms { get ; set ; }
133
125
@@ -399,74 +391,31 @@ protected override void ExecuteCore()
399
391
_normalizedTargetFrameworkVersion ??= NormalizeVersion ( new Version ( TargetFrameworkVersion ) ) ;
400
392
packagesToDownload ??= new List < ITaskItem > ( ) ;
401
393
402
- List < ITaskItem > implicitPackageReferences = new List < ITaskItem > ( ) ;
394
+ List < ITaskItem > implicitPackageReferences = new ( ) ;
395
+ List < ITaskItem > unavailableToolPacks = new ( ) ;
403
396
404
397
if ( ReadyToRunEnabled && ReadyToRunUseCrossgen2 )
405
398
{
406
- if ( AddToolPack ( ToolPackType . Crossgen2 , _normalizedTargetFrameworkVersion , packagesToDownload , implicitPackageReferences ) is not ToolPackSupport . Supported )
407
- {
408
- Log . LogError ( Strings . ReadyToRunNoValidRuntimePackageError ) ;
399
+ if ( ! AddToolPack ( ToolPackType . Crossgen2 , _normalizedTargetFrameworkVersion , unavailableToolPacks , packagesToDownload , implicitPackageReferences ) )
409
400
return ;
410
- }
411
401
}
412
402
413
403
if ( PublishAot )
414
404
{
415
- switch ( AddToolPack ( ToolPackType . ILCompiler , _normalizedTargetFrameworkVersion , packagesToDownload , implicitPackageReferences ) )
416
- {
417
- case ToolPackSupport . UnsupportedForTargetFramework :
418
- Log . LogError ( Strings . AotUnsupportedTargetFramework ) ;
419
- return ;
420
- case ToolPackSupport . UnsupportedForHostRuntimeIdentifier :
421
- Log . LogError ( Strings . AotUnsupportedHostRuntimeIdentifier , NETCoreSdkRuntimeIdentifier ) ;
422
- return ;
423
- case ToolPackSupport . UnsupportedForTargetRuntimeIdentifier :
424
- Log . LogError ( Strings . AotUnsupportedTargetRuntimeIdentifier , RuntimeIdentifier ) ;
425
- return ;
426
- case ToolPackSupport . Supported :
427
- break ;
428
- }
405
+ if ( ! AddToolPack ( ToolPackType . ILCompiler , _normalizedTargetFrameworkVersion , unavailableToolPacks , packagesToDownload , implicitPackageReferences ) )
406
+ return ;
429
407
}
430
408
431
409
if ( RequiresILLinkPack )
432
410
{
433
- if ( AddToolPack ( ToolPackType . ILLink , _normalizedTargetFrameworkVersion , packagesToDownload , implicitPackageReferences ) is not ToolPackSupport . Supported )
434
- {
435
- // Keep the checked properties in sync with _RequiresILLinkPack in Microsoft.NET.Publish.targets.
436
- if ( PublishAot ) {
437
- // If PublishAot is set, this should produce a specific error above already.
438
- // Also produce one here just in case there are custom KnownILCompilerPack/KnownILLinkPack
439
- // items that bypass the error above.
440
- Log . LogError ( Strings . AotUnsupportedTargetFramework ) ;
441
- } else if ( IsAotCompatible || EnableAotAnalyzer ) {
442
- // Technically this is reachable by setting EnableAotAnalyzer without IsAotCompatible,
443
- // but the recommended way to enable AOT analysis is to set IsAotCompatible,
444
- // so the warning points to the common case.
445
- Log . LogWarning ( Strings . IsAotCompatibleUnsupported ) ;
446
- } else if ( PublishTrimmed ) {
447
- Log . LogError ( Strings . PublishTrimmedRequiresVersion30 ) ;
448
- } else if ( IsTrimmable || EnableTrimAnalyzer ) {
449
- // Technically this is reachable by setting EnableTrimAnalyzer without IsTrimmable,
450
- // but the recommended way to enable trim analysis is to set IsTrimmable,
451
- // so the warning points to the common case.
452
- Log . LogWarning ( Strings . IsTrimmableUnsupported ) ;
453
- } else if ( EnableSingleFileAnalyzer ) {
454
- // There's no IsSingleFileCompatible setting. EnableSingleFileAnalyzer is the
455
- // recommended way to ensure single-file compatibility for libraries.
456
- Log . LogWarning ( Strings . EnableSingleFileAnalyzerUnsupported ) ;
457
- } else {
458
- // _RequiresILLinkPack was set. This setting acts as an override for the
459
- // user-visible properties, and should generally only be used by
460
- // other SDKs that can't use the other properties for some reason.
461
- Log . LogError ( Strings . ILLinkNoValidRuntimePackageError ) ;
462
- }
463
- }
411
+ AddToolPack ( ToolPackType . ILLink , _normalizedTargetFrameworkVersion , unavailableToolPacks , packagesToDownload , implicitPackageReferences ) ;
412
+
464
413
}
465
414
466
415
if ( UsingMicrosoftNETSdkWebAssembly )
467
416
{
468
417
// WebAssemblySdk is used for .NET >= 6, it's ok if no pack is added.
469
- AddToolPack ( ToolPackType . WebAssemblySdk , _normalizedTargetFrameworkVersion , packagesToDownload , implicitPackageReferences ) ;
418
+ AddToolPack ( ToolPackType . WebAssemblySdk , _normalizedTargetFrameworkVersion , unavailableToolPacks , packagesToDownload , implicitPackageReferences ) ;
470
419
}
471
420
472
421
if ( packagesToDownload . Any ( ) )
@@ -499,6 +448,11 @@ protected override void ExecuteCore()
499
448
ImplicitPackageReferences = implicitPackageReferences . ToArray ( ) ;
500
449
}
501
450
451
+ if ( unavailableToolPacks . Any ( ) )
452
+ {
453
+ UnavailableToolPacks = unavailableToolPacks . ToArray ( ) ;
454
+ }
455
+
502
456
if ( knownRuntimePacksForTargetFramework ? . Any ( ) == true )
503
457
{
504
458
// Determine the known runtime identifier platforms based on all available Microsoft.NETCore.App packs
@@ -708,9 +662,10 @@ enum ToolPackSupport {
708
662
Supported
709
663
}
710
664
711
- private ToolPackSupport AddToolPack (
665
+ private bool AddToolPack (
712
666
ToolPackType toolPackType ,
713
667
Version normalizedTargetFrameworkVersion ,
668
+ List < ITaskItem > unavailableToolPacks ,
714
669
List < ITaskItem > packagesToDownload ,
715
670
List < ITaskItem > implicitPackageReferences )
716
671
{
@@ -730,12 +685,15 @@ private ToolPackSupport AddToolPack(
730
685
NormalizeVersion ( packTargetFramework . Version ) == normalizedTargetFrameworkVersion ;
731
686
} ) . SingleOrDefault ( ) ;
732
687
688
+ var packName = toolPackType . ToString ( ) ;
733
689
if ( knownPack == null )
734
690
{
735
- return ToolPackSupport . UnsupportedForTargetFramework ;
691
+ var unavailableToolPack = new TaskItem ( packName ) ;
692
+ unavailableToolPack . SetMetadata ( MetadataKeys . ToolPackSupport , ToolPackSupport . UnsupportedForTargetFramework . ToString ( ) ) ;
693
+ unavailableToolPacks . Add ( unavailableToolPack ) ;
694
+ return false ;
736
695
}
737
696
738
- var packName = toolPackType . ToString ( ) ;
739
697
var packVersion = knownPack . GetMetadata ( packName + "PackVersion" ) ;
740
698
if ( ! string . IsNullOrEmpty ( RuntimeFrameworkVersion ) )
741
699
{
@@ -755,7 +713,10 @@ private ToolPackSupport AddToolPack(
755
713
var hostRuntimeIdentifier = NuGetUtils . GetBestMatchingRid ( runtimeGraph , NETCoreSdkRuntimeIdentifier , packSupportedRuntimeIdentifiers , out bool wasInGraph ) ;
756
714
if ( hostRuntimeIdentifier == null )
757
715
{
758
- return ToolPackSupport . UnsupportedForHostRuntimeIdentifier ;
716
+ var unavailableToolPack = new TaskItem ( packName ) ;
717
+ unavailableToolPack . SetMetadata ( MetadataKeys . ToolPackSupport , ToolPackSupport . UnsupportedForHostRuntimeIdentifier . ToString ( ) ) ;
718
+ unavailableToolPacks . Add ( unavailableToolPack ) ;
719
+ return false ;
759
720
}
760
721
761
722
var runtimePackName = packNamePattern . Replace ( "**RID**" , hostRuntimeIdentifier ) ;
@@ -785,7 +746,10 @@ private ToolPackSupport AddToolPack(
785
746
var targetRuntimeIdentifier = NuGetUtils . GetBestMatchingRid ( runtimeGraph , RuntimeIdentifier , packSupportedRuntimeIdentifiers , out bool wasInGraph2 ) ;
786
747
if ( targetRuntimeIdentifier == null )
787
748
{
788
- return ToolPackSupport . UnsupportedForTargetRuntimeIdentifier ;
749
+ var unavailableToolPack = new TaskItem ( packName ) ;
750
+ unavailableToolPack . SetMetadata ( MetadataKeys . ToolPackSupport , ToolPackSupport . UnsupportedForTargetRuntimeIdentifier . ToString ( ) ) ;
751
+ unavailableToolPacks . Add ( unavailableToolPack ) ;
752
+ return false ;
789
753
}
790
754
if ( ! hostRuntimeIdentifier . Equals ( targetRuntimeIdentifier ) )
791
755
{
@@ -828,7 +792,7 @@ private ToolPackSupport AddToolPack(
828
792
implicitPackageReferences . Add ( analyzerPackage ) ;
829
793
}
830
794
831
- return ToolPackSupport . Supported ;
795
+ return true ;
832
796
}
833
797
834
798
private string GetRuntimeFrameworkVersion (
0 commit comments