Update projectmodel server
Reflecting the xproj reference changes in ProjectModel
This commit is contained in:
parent
698c82915e
commit
e23f08e7ac
25 changed files with 671 additions and 38 deletions
|
@ -4,11 +4,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.DotNet.ProjectModel.Compilation;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Helpers;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Models;
|
||||
using Microsoft.DotNet.Cli.Compiler.Common;
|
||||
using NuGet.Frameworks;
|
||||
using Microsoft.DotNet.ProjectModel.Graph;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server
|
||||
{
|
||||
|
@ -51,15 +51,13 @@ namespace Microsoft.DotNet.ProjectModel.Server
|
|||
var description = DependencyDescription.Create(export.Library, diagnostics, allExports);
|
||||
allDependencies[description.Name] = description;
|
||||
|
||||
var projectDescription = export.Library as ProjectDescription;
|
||||
if (projectDescription != null)
|
||||
var projectReferene = ProjectReferenceDescription.Create(export.Library);
|
||||
if (projectReferene != null && export.Library.Identity.Name != context.ProjectFile.Name)
|
||||
{
|
||||
if (projectDescription.Identity.Name != context.ProjectFile.Name)
|
||||
{
|
||||
allProjectReferences.Add(ProjectReferenceDescription.Create(projectDescription));
|
||||
}
|
||||
allProjectReferences.Add(projectReferene);
|
||||
}
|
||||
else
|
||||
|
||||
if (export.Library.Identity.Type != LibraryType.Project)
|
||||
{
|
||||
allFileReferences.AddRange(export.CompilationAssemblies.Select(asset => asset.ResolvedPath));
|
||||
}
|
||||
|
|
|
@ -5,13 +5,12 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using Microsoft.DotNet.ProjectModel.Compilation;
|
||||
using Microsoft.DotNet.ProjectModel.Graph;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Helpers;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Models
|
||||
{
|
||||
public class DependencyDescription
|
||||
{
|
||||
private DependencyDescription() { }
|
||||
protected DependencyDescription() { }
|
||||
|
||||
public string Name { get; private set; }
|
||||
|
||||
|
@ -24,6 +23,8 @@ namespace Microsoft.DotNet.ProjectModel.Server.Models
|
|||
public string Type { get; private set; }
|
||||
|
||||
public bool Resolved { get; private set; }
|
||||
|
||||
public string MSBuildProjectPath { get; private set; }
|
||||
|
||||
public IEnumerable<DependencyItem> Dependencies { get; private set; }
|
||||
|
||||
|
@ -57,7 +58,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Models
|
|||
List<DiagnosticMessage> diagnostics,
|
||||
IDictionary<string, LibraryExport> exportsLookup)
|
||||
{
|
||||
return new DependencyDescription
|
||||
var result = new DependencyDescription
|
||||
{
|
||||
Name = library.Identity.Name,
|
||||
DisplayName = library.Identity.Name,
|
||||
|
@ -71,6 +72,14 @@ namespace Microsoft.DotNet.ProjectModel.Server.Models
|
|||
Warnings = diagnostics.Where(d => d.Severity == DiagnosticMessageSeverity.Warning)
|
||||
.Select(d => new DiagnosticMessageView(d))
|
||||
};
|
||||
|
||||
var msbuildLibrary = library as MSBuildProjectDescription;
|
||||
if (msbuildLibrary != null)
|
||||
{
|
||||
result.MSBuildProjectPath = msbuildLibrary.ProjectLibrary.MSBuildProject;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static DependencyItem GetDependencyItem(LibraryRange dependency,
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using NuGet.Frameworks;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Models
|
||||
{
|
||||
internal class ProjectReferenceDescription
|
||||
|
@ -12,7 +10,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Models
|
|||
public FrameworkData Framework { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string WrappedProjectPath { get; set; }
|
||||
public string MSBuildProjectPath { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
|
@ -20,36 +18,43 @@ namespace Microsoft.DotNet.ProjectModel.Server.Models
|
|||
return other != null &&
|
||||
string.Equals(Name, other.Name) &&
|
||||
string.Equals(Path, other.Path) &&
|
||||
string.Equals(WrappedProjectPath, other.WrappedProjectPath);
|
||||
string.Equals(MSBuildProjectPath, other.MSBuildProjectPath);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public static ProjectReferenceDescription Create(ProjectDescription description)
|
||||
|
||||
/// <summary>
|
||||
/// Create a ProjectReferenceDescription from given LibraryDescription. If the library doesn't
|
||||
/// represent a project reference returns null.
|
||||
/// </summary>
|
||||
public static ProjectReferenceDescription Create(LibraryDescription library)
|
||||
{
|
||||
var targetFrameworkInformation = description.TargetFrameworkInfo;
|
||||
|
||||
string wrappedProjectPath = null;
|
||||
if (!string.IsNullOrEmpty(targetFrameworkInformation?.WrappedProject) &&
|
||||
description.Project != null)
|
||||
if (library is ProjectDescription)
|
||||
{
|
||||
wrappedProjectPath = System.IO.Path.Combine(
|
||||
description.Project.ProjectDirectory,
|
||||
targetFrameworkInformation.WrappedProject);
|
||||
|
||||
wrappedProjectPath = System.IO.Path.GetFullPath(wrappedProjectPath);
|
||||
return new ProjectReferenceDescription
|
||||
{
|
||||
Framework = library.Framework.ToPayload(),
|
||||
Name = library.Identity.Name,
|
||||
Path = library.Path
|
||||
};
|
||||
}
|
||||
|
||||
return new ProjectReferenceDescription
|
||||
else if (library is MSBuildProjectDescription)
|
||||
{
|
||||
Framework = description.Framework.ToPayload(),
|
||||
Name = description.Identity.Name,
|
||||
Path = description.Path,
|
||||
WrappedProjectPath = wrappedProjectPath,
|
||||
};
|
||||
return new ProjectReferenceDescription
|
||||
{
|
||||
Framework = library.Framework.ToPayload(),
|
||||
Name = library.Identity.Name,
|
||||
Path = library.Path,
|
||||
MSBuildProjectPath = ((MSBuildProjectDescription)library).ProjectLibrary.MSBuildProject
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue