Distinguish between the msbuild project path and csproj file path

This commit is contained in:
Mihai Codoban 2016-03-30 16:26:00 -07:00
parent fd3a7a0a5f
commit b7ca1d14bd
2 changed files with 15 additions and 6 deletions

View file

@ -10,11 +10,15 @@ namespace Microsoft.DotNet.ProjectModel
/// <summary> /// <summary>
/// Represents an MSBuild project. /// Represents an MSBuild project.
/// It has been invisibly built by MSBuild, so it behaves like a package: can provide all assets up front /// It has been invisibly built by MSBuild, so it behaves like a package: can provide all assets up front
///
/// Path points to the project's directory
/// MSBuildPRojectPath points to the csproj file
/// </summary> /// </summary>
public class MSBuildProjectDescription : TargetLibraryWithAssets public class MSBuildProjectDescription : TargetLibraryWithAssets
{ {
public MSBuildProjectDescription( public MSBuildProjectDescription(
string path, string path,
string msbuildProjectPath,
LockFileProjectLibrary projectLibrary, LockFileProjectLibrary projectLibrary,
LockFileTargetLibrary lockFileLibrary, LockFileTargetLibrary lockFileLibrary,
Project projectFile, Project projectFile,
@ -31,12 +35,15 @@ namespace Microsoft.DotNet.ProjectModel
compatible: compatible, compatible: compatible,
framework: null) framework: null)
{ {
MSBuildProjectPath = msbuildProjectPath;
ProjectFile = projectFile; ProjectFile = projectFile;
ProjectLibrary = projectLibrary; ProjectLibrary = projectLibrary;
} }
public LockFileProjectLibrary ProjectLibrary { get; } public LockFileProjectLibrary ProjectLibrary { get; }
public string MSBuildProjectPath { get; set; }
public Project ProjectFile { get; } public Project ProjectFile { get; }
} }
} }

View file

@ -30,13 +30,16 @@ namespace Microsoft.DotNet.ProjectModel.Resolution
var dependencies = new List<LibraryRange>(targetLibrary.Dependencies.Count + targetLibrary.FrameworkAssemblies.Count); var dependencies = new List<LibraryRange>(targetLibrary.Dependencies.Count + targetLibrary.FrameworkAssemblies.Count);
PopulateDependencies(dependencies, targetLibrary, targetFramework); PopulateDependencies(dependencies, targetLibrary, targetFramework);
var msbuildProjectPath = GetMSbuildProjectPath(projectLibrary); var msbuildProjectFilePath = GetMSBuildProjectFilePath(projectLibrary);
var exists = Directory.Exists(msbuildProjectPath); var msbuildProjectDirectoryPath = Path.GetDirectoryName(msbuildProjectFilePath);
var exists = Directory.Exists(msbuildProjectDirectoryPath);
var projectFile = projectLibrary.Path == null ? null : _projectResolver(projectLibrary.Path); var projectFile = projectLibrary.Path == null ? null : _projectResolver(projectLibrary.Path);
var msbuildPackageDescription = new MSBuildProjectDescription( var msbuildPackageDescription = new MSBuildProjectDescription(
msbuildProjectPath, msbuildProjectDirectoryPath,
msbuildProjectFilePath,
projectLibrary, projectLibrary,
targetLibrary, targetLibrary,
projectFile, projectFile,
@ -47,7 +50,7 @@ namespace Microsoft.DotNet.ProjectModel.Resolution
return msbuildPackageDescription; return msbuildPackageDescription;
} }
private string GetMSbuildProjectPath(LockFileProjectLibrary projectLibrary) private string GetMSBuildProjectFilePath(LockFileProjectLibrary projectLibrary)
{ {
if (_rootProject == null) if (_rootProject == null)
{ {
@ -56,9 +59,8 @@ namespace Microsoft.DotNet.ProjectModel.Resolution
var rootProjectPath = Path.GetDirectoryName(_rootProject.ProjectFilePath); var rootProjectPath = Path.GetDirectoryName(_rootProject.ProjectFilePath);
var msbuildProjectFilePath = Path.Combine(rootProjectPath, projectLibrary.MSBuildProject); var msbuildProjectFilePath = Path.Combine(rootProjectPath, projectLibrary.MSBuildProject);
var msbuildProjectPath = Path.GetDirectoryName(Path.GetFullPath(msbuildProjectFilePath));
return msbuildProjectPath; return Path.GetFullPath(msbuildProjectFilePath);
} }
private void PopulateDependencies( private void PopulateDependencies(