Skip to content

Commit

Permalink
Try recurs
Browse files Browse the repository at this point in the history
  • Loading branch information
rstm-sf committed Apr 23, 2021
1 parent 25f2335 commit 77ec10e
Showing 1 changed file with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,25 +164,38 @@ private bool TryResolvePreviewInfoCommon(out PreviewInfo previewInfo, string[] t
return false;
}

isSuccess = BuildEngine.BuildProjectFile(ProjectFile, TargetGetProjectReference, props, targetOutputs);
var xamlFileInfoCollection = ResolveReferenceXamlFileInfoCollection(
previewInfo.XamlFileInfo.ProjectPath, props);
previewInfo.XamlFileInfo.ReferenceXamlFileInfoCollection = xamlFileInfoCollection;

return true;
}

private List<XamlFileInfo> ResolveReferenceXamlFileInfoCollection(
string parentProjectPath, Dictionary<string, string> props)
{
var targetOutputs = new Dictionary<string, ITaskItem[]>();
var xamlFileInfoCollection = new List<XamlFileInfo>();
var isSuccess = BuildEngine.BuildProjectFile(
parentProjectPath, TargetGetProjectReference, props, targetOutputs);
if (isSuccess)
{
var currentProjectDirectory = Directory.GetParent(previewInfo.XamlFileInfo.ProjectPath).FullName;
var currentProjectDirectory = Directory.GetParent(parentProjectPath)!.FullName;

var projectReferenceCollection = targetOutputs.ResultFromArray(SelectInfoProjectReference);
var xamlFileInfoCollection = new List<XamlFileInfo>(projectReferenceCollection.Length);
foreach (var project in projectReferenceCollection)
{
if (string.IsNullOrEmpty(project))
continue;

var path = Path.Combine(currentProjectDirectory, project);
isSuccess = TryResolvePreviewInfoCommonProjectReference(path, out var xamlFileInfo);
if (isSuccess)
xamlFileInfoCollection.Add(xamlFileInfo);
}

previewInfo.XamlFileInfo.ReferenceXamlFileInfoCollection = xamlFileInfoCollection;
}

return true;
return xamlFileInfoCollection;
}

private bool TryResolvePreviewInfoCommonProjectReference(string projectReference, out XamlFileInfo xamlFileInfo)
Expand All @@ -200,13 +213,21 @@ private bool TryResolvePreviewInfoCommonProjectReference(string projectReference
if (!isSuccess)
return false;

var projectPath = targetOutputs.ResultFromSingle(SelectInfoProjectPath);
// The project can be build, but in reality it cannot
if (string.IsNullOrEmpty(projectPath))
return false;

xamlFileInfo = new XamlFileInfo
{
ProjectPath = targetOutputs.ResultFromSingle(SelectInfoProjectPath),
ProjectPath = projectPath,
AvaloniaResource = targetOutputs.ResultFromArrayAsSingleSkipNonXaml(SelectInfoAvaloniaResource),
AvaloniaXaml = targetOutputs.ResultFromArrayAsSingle(SelectInfoAvaloniaXaml),
};

xamlFileInfo.ReferenceXamlFileInfoCollection = ResolveReferenceXamlFileInfoCollection(
xamlFileInfo.ProjectPath, props);

return true;
}

Expand Down

0 comments on commit 77ec10e

Please sign in to comment.