Skip to content

Commit

Permalink
Skip library
Browse files Browse the repository at this point in the history
  • Loading branch information
rstm-sf committed May 29, 2021
1 parent a2e16e7 commit 44fd86a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

<Target Name="SelectInfoProjectReference" Returns="@(ProjectReference)" />
<Target Name="SelectInfoProjectPath" Returns="$(ProjectPath)" />
<Target Name="SelectInfoOutputType" Returns="$(OutputType)" />

<Target Name="SelectInfoAvaloniaResource" Returns="@(AvaloniaResource)" />
<Target Name="SelectInfoAvaloniaXaml" Returns="@(AvaloniaXaml)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class PreviewInfoResolverTask : ContextAwareTask
// ReSharper disable InconsistentNaming
private const string SelectInfoProjectReference = nameof(SelectInfoProjectReference);
private const string SelectInfoProjectPath = nameof(SelectInfoProjectPath);
private const string SelectInfoOutputType = nameof(SelectInfoOutputType);
private const string SelectInfoAvaloniaResource = nameof(SelectInfoAvaloniaResource);
private const string SelectInfoAvaloniaXaml = nameof(SelectInfoAvaloniaXaml);
private const string SelectInfoAvaloniaPreviewerNetCoreToolPath =
Expand Down Expand Up @@ -53,6 +54,8 @@ public class PreviewInfoResolverTask : ContextAwareTask

private static readonly string[] TargetGetProjectReference = {SelectInfoProjectReference};

private static readonly string[] TargetGetOutput = {SelectInfoOutputType};

private static readonly string[] TargetGetTfms = {SelectInfoTargetFrameworks};

private readonly Dictionary<string, string> _globalPropertiesCommon;
Expand Down Expand Up @@ -90,6 +93,12 @@ public PreviewInfoResolverTask()

protected override bool ExecuteInner()
{
if (!TryResolvePreviewInfoOutputType(ProjectFile, out var outputType))
return false;

if (outputType == "Library")
return false;

if (!TryResolvePreviewInfoTfms(ProjectFile, out var targetFrameworks))
return false;

Expand All @@ -109,6 +118,20 @@ protected override bool ExecuteInner()
return true;
}

private bool TryResolvePreviewInfoOutputType(string projectFile, out string outputType)
{
var targetOutputs = new Dictionary<string, ITaskItem[]>();

if (BuildEngine.BuildProjectFile(projectFile, TargetGetOutput, _globalPropertiesCommon, targetOutputs))
{
outputType = targetOutputs.ResultFromSingle(SelectInfoOutputType);
return true;
}

outputType = default!;
return false;
}

private bool TryResolvePreviewInfoTfms(string projectFile, out string[] targetFrameworks)
{
var targetOutputs = new Dictionary<string, ITaskItem[]>();
Expand Down

0 comments on commit 44fd86a

Please sign in to comment.