Skip to content
Permalink
Browse files

[Assets] Better resolution of project platform (needed so that window…

…s project is auto selected)
  • Loading branch information
xen2 committed Nov 25, 2018
1 parent 0280495 commit 025f2fedbe1ebf73927fcf89d641593e9879c0bc
Showing with 26 additions and 3 deletions.
  1. +26 −3 sources/assets/Xenko.Core.Assets/PackageSession.Dependencies.cs
@@ -94,7 +94,7 @@ private async Task PreLoadPackageDependencies(ILogger log, SolutionProject proje
// Load some informations about the project
try
{
var msProject = VSProjectHelper.LoadProject(project.FullPath, extraProperties: new Dictionary<string, string> { { "SkipInvalidConfigurations", "true" }, { "ExcludeRestorePackageImports", "true" } });
var msProject = VSProjectHelper.LoadProject(project.FullPath, extraProperties: new Dictionary<string, string> { { "SkipInvalidConfigurations", "true" } });
try
{
var packageVersion = msProject.GetPropertyValue("PackageVersion");
@@ -111,8 +111,9 @@ private async Task PreLoadPackageDependencies(ILogger log, SolutionProject proje
? ProjectType.Executable
: ProjectType.Library;

// TODO: Platform might be incorrect if Xenko is not restored yet (it won't include Xenko targets)
if (project.Type == ProjectType.Executable)
// Note: Platform might be incorrect if Xenko is not restored yet (it won't include Xenko targets)
// Also, if already set, don't try to query it again
if (project.Type == ProjectType.Executable && project.Platform == PlatformType.Shared)
project.Platform = VSProjectHelper.GetPlatformTypeFromProject(msProject) ?? PlatformType.Shared;

foreach (var packageReference in msProject.GetItems("PackageReference").ToList())
@@ -230,6 +231,28 @@ private async Task PreLoadPackageDependencies(ILogger log, SolutionProject proje
if (loadParameters.AutoCompileProjects)
await VSProjectHelper.RestoreNugetPackages(log, project.FullPath);

// If platform was unknown (due to missing nuget packages during first pass), check it again
if (project.Type == ProjectType.Executable && project.Platform == PlatformType.Shared)
{
try
{
var msProject = VSProjectHelper.LoadProject(project.FullPath, extraProperties: new Dictionary<string, string> { { "SkipInvalidConfigurations", "true" } });
try
{
project.Platform = VSProjectHelper.GetPlatformTypeFromProject(msProject) ?? PlatformType.Shared;
}
finally
{
msProject.ProjectCollection.UnloadAllProjects();
msProject.ProjectCollection.Dispose();
}
}
catch (Exception ex)
{
log.Error($"Unexpected exception while loading project [{project.FullPath.ToWindowsPath()}]", ex);
}
}

project.FlattenedDependencies.Clear();
project.DirectDependencies.Clear();
var projectAssetsJsonPath = Path.Combine(project.FullPath.GetFullDirectory(), @"obj", LockFileFormat.AssetsFileName);

0 comments on commit 025f2fe

Please sign in to comment.
You can’t perform that action at this time.