Skip to content
Permalink
Browse files

[Assets] project.Type evaluation needs to be done after package are r…

…estored
  • Loading branch information
xen2 committed Nov 1, 2018
1 parent 79dedb7 commit ed826ce2de64990215c51cd5cd84f08193e49120
Showing with 24 additions and 6 deletions.
  1. +24 −6 sources/assets/Xenko.Core.Assets/PackageSession.Dependencies.cs
@@ -98,12 +98,6 @@ private async Task PreLoadPackageDependencies(ILogger log, SolutionProject proje
var msProject = VSProjectHelper.LoadProject(project.FullPath, platform: "NoPlatform");
try
{

var projectIsExecutable = msProject.GetPropertyValue("XenkoIsExecutable");
project.Type = projectIsExecutable.ToLowerInvariant() == "true" ? ProjectType.Executable : ProjectType.Library;
if (project.Type == ProjectType.Executable)
project.Platform = VSProjectHelper.GetPlatformTypeFromProject(msProject) ?? PlatformType.Shared;

foreach (var packageReference in msProject.GetItems("PackageReference").ToList())
{
if (packageReference.HasMetadata("Version") && PackageVersionRange.TryParse(packageReference.GetMetadataValue("Version"), out var packageRange))
@@ -218,6 +212,30 @@ private async Task PreLoadPackageDependencies(ILogger log, SolutionProject proje
log.Verbose($"Restore NuGet packages for {project.Name}...");
await VSProjectHelper.RestoreNugetPackages(log, project.FullPath);

// Load some informations about the project
try
{
// Load a project without specifying a platform to make sure we get the correct platform type
var msProject = VSProjectHelper.LoadProject(project.FullPath, platform: "NoPlatform");
try
{

var projectIsExecutable = msProject.GetPropertyValue("OutputType");
project.Type = projectIsExecutable.ToLowerInvariant() == "winexe" || projectIsExecutable.ToLowerInvariant() == "exe" ? ProjectType.Executable : ProjectType.Library;
if (project.Type == ProjectType.Executable)
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 ed826ce

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