@@ -18,6 +18,7 @@ public class PreviewInfoResolverTask : ContextAwareTask
1818 // ReSharper disable InconsistentNaming
1919 private const string SelectInfoProjectReference = nameof ( SelectInfoProjectReference ) ;
2020 private const string SelectInfoProjectPath = nameof ( SelectInfoProjectPath ) ;
21+ private const string SelectInfoOutputType = nameof ( SelectInfoOutputType ) ;
2122 private const string SelectInfoAvaloniaResource = nameof ( SelectInfoAvaloniaResource ) ;
2223 private const string SelectInfoAvaloniaXaml = nameof ( SelectInfoAvaloniaXaml ) ;
2324 private const string SelectInfoAvaloniaPreviewerNetCoreToolPath =
@@ -53,6 +54,8 @@ public class PreviewInfoResolverTask : ContextAwareTask
5354
5455 private static readonly string [ ] TargetGetProjectReference = { SelectInfoProjectReference } ;
5556
57+ private static readonly string [ ] TargetGetOutput = { SelectInfoOutputType } ;
58+
5659 private static readonly string [ ] TargetGetTfms = { SelectInfoTargetFrameworks } ;
5760
5861 private readonly Dictionary < string , string > _globalPropertiesCommon ;
@@ -90,6 +93,12 @@ public PreviewInfoResolverTask()
9093
9194 protected override bool ExecuteInner ( )
9295 {
96+ if ( ! TryResolvePreviewInfoOutputType ( ProjectFile , out var outputType ) )
97+ return false ;
98+
99+ if ( outputType == "Library" )
100+ return false ;
101+
93102 if ( ! TryResolvePreviewInfoTfms ( ProjectFile , out var targetFrameworks ) )
94103 return false ;
95104
@@ -109,6 +118,20 @@ protected override bool ExecuteInner()
109118 return true ;
110119 }
111120
121+ private bool TryResolvePreviewInfoOutputType ( string projectFile , out string outputType )
122+ {
123+ var targetOutputs = new Dictionary < string , ITaskItem [ ] > ( ) ;
124+
125+ if ( BuildEngine . BuildProjectFile ( projectFile , TargetGetOutput , _globalPropertiesCommon , targetOutputs ) )
126+ {
127+ outputType = targetOutputs . ResultFromSingle ( SelectInfoOutputType ) ;
128+ return true ;
129+ }
130+
131+ outputType = default ! ;
132+ return false ;
133+ }
134+
112135 private bool TryResolvePreviewInfoTfms ( string projectFile , out string [ ] targetFrameworks )
113136 {
114137 var targetOutputs = new Dictionary < string , ITaskItem [ ] > ( ) ;
0 commit comments