Skip to content

Commit 44fd86a

Browse files
committed
Skip library
1 parent a2e16e7 commit 44fd86a

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/AvaloniaProjectInfoResolver.PreviewTask/AvaloniaProjectInfoResolver.PreviewInner.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
<Target Name="SelectInfoProjectReference" Returns="@(ProjectReference)" />
55
<Target Name="SelectInfoProjectPath" Returns="$(ProjectPath)" />
6+
<Target Name="SelectInfoOutputType" Returns="$(OutputType)" />
67

78
<Target Name="SelectInfoAvaloniaResource" Returns="@(AvaloniaResource)" />
89
<Target Name="SelectInfoAvaloniaXaml" Returns="@(AvaloniaXaml)" />

src/AvaloniaProjectInfoResolver.PreviewTask/PreviewInfoResolverTask.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)