Skip to content

Commit

Permalink
Merge pull request #1442 from BrunoJuchli/patch-2
Browse files Browse the repository at this point in the history
Fix #1435 - calculation of ResolvedPath for project references
  • Loading branch information
nguerrera authored Oct 30, 2017
2 parents f5cda4d + 38c3068 commit 634680a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Microsoft.NET.Build.Tasks.UnitTests
public class GivenAResolvePackageDependenciesTask
{
private static readonly string _packageRoot = "\\root\\packages".Replace('\\', Path.DirectorySeparatorChar);
private static readonly string _projectPath = "\\root\\anypath\\solutiondirectory\\myprojectdir\\myproject.csproj".Replace('\\', Path.DirectorySeparatorChar);

[Theory]
[MemberData(nameof(ItemCounts))]
Expand Down Expand Up @@ -254,8 +255,8 @@ public void ItAssignsPackageDefinitionMetadata()
package.GetMetadata(MetadataKeys.Type).Should().Be("project");
package.GetMetadata(MetadataKeys.Path).Should().Be($"../ClassLibP/project.json");

var resolvedPath = Path.GetDirectoryName(Path.GetFullPath(lockFile.Path));
resolvedPath = Path.GetFullPath(Path.Combine(resolvedPath, "../ClassLibP/ClassLibP.csproj"));
var projectDirectoryPath = Path.GetDirectoryName(Path.GetFullPath(_projectPath));
var resolvedPath = Path.GetFullPath(Path.Combine(projectDirectoryPath, "../ClassLibP/ClassLibP.csproj"));
package.GetMetadata(MetadataKeys.ResolvedPath).Should().Be(resolvedPath);
}
else
Expand Down Expand Up @@ -796,7 +797,7 @@ private ResolvePackageDependencies GetExecutedTask(LockFile lockFile)
var task = new ResolvePackageDependencies(lockFile, resolver)
{
ProjectAssetsFile = lockFile.Path,
ProjectPath = null,
ProjectPath = _projectPath,
ProjectLanguage = null
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ private string ResolveFilePath(string relativePath, string resolvedPackagePath)

private string GetAbsolutePathFromProjectRelativePath(string path)
{
return Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Path.GetFullPath(ProjectAssetsFile)), path));
return Path.GetFullPath(Path.Combine(Path.GetDirectoryName(ProjectPath), path));
}
}
}

0 comments on commit 634680a

Please sign in to comment.