diff --git a/src/AvaloniaProjectInfoResolver.PreviewTask/PreviewInfoResolverTask.cs b/src/AvaloniaProjectInfoResolver.PreviewTask/PreviewInfoResolverTask.cs index 2169d97..69cd4ff 100644 --- a/src/AvaloniaProjectInfoResolver.PreviewTask/PreviewInfoResolverTask.cs +++ b/src/AvaloniaProjectInfoResolver.PreviewTask/PreviewInfoResolverTask.cs @@ -200,13 +200,18 @@ private List ResolveReferenceXamlFileInfoCollection( // ReSharper disable once InvertIf if (TryResolvePreviewInfoCommonProjectReference(path, projectReadiesInner, out var xamlFileInfo)) { - xamlFileInfoCollection.Add(new XamlFileInfo - { - ProjectPath = xamlFileInfo.ProjectPath, - AvaloniaResource = xamlFileInfo.AvaloniaResource, - AvaloniaXaml = xamlFileInfo.AvaloniaXaml, - }); - xamlFileInfoCollection.AddRange(xamlFileInfo.ReferenceXamlFileInfoCollection); + if (ShouldContainsAvaloniaXaml(xamlFileInfo)) + xamlFileInfoCollection.Add(new XamlFileInfo + { + ProjectPath = xamlFileInfo.ProjectPath, + AvaloniaResource = xamlFileInfo.AvaloniaResource, + AvaloniaXaml = xamlFileInfo.AvaloniaXaml, + }); + + xamlFileInfoCollection.AddRange( + xamlFileInfo.ReferenceXamlFileInfoCollection + .Where(x => + ShouldContainsAvaloniaXaml(x) || x.ReferenceXamlFileInfoCollection.Count > 0)); projectReadiesInner.Add(xamlFileInfo.ProjectPath); projectReadiesInner.AddRange(xamlFileInfo.ReferenceXamlFileInfoCollection.Select(x => x.ProjectPath)); @@ -321,6 +326,9 @@ private void SendMessage(PreviewInfo previewInfo) } } + private static bool ShouldContainsAvaloniaXaml(XamlFileInfo value) => + !(string.IsNullOrEmpty(value.AvaloniaResource) && string.IsNullOrEmpty(value.AvaloniaXaml)); + // ReSharper disable once InconsistentNaming private static PreviewInfo SelectPreviewInfoCommon(Dictionary targetOutputs) => new()