Skip to content

Update ResolvePackageDependencies task to support Dependencies node Plus Tests - #103

Merged
natidea merged 7 commits into
dotnet:masterfrom
natidea:pdTask
Aug 31, 2016
Merged

natidea merged 7 commits into
dotnet:masterfrom
natidea:pdTask

Conversation

@natidea

@natidea natidea commented Aug 29, 2016

Copy link
Copy Markdown
Contributor

Fix a number of issues in ResolvePackageDependencies task to better support Dependencies node in solution explorer, including:

  • Filter top level package dependencies to those that are project file dependencies
  • Add analyzers to file dependencies
  • Change "Type" metadata for analyzers to AnalyzerAssembly
  • Filter out _._ files

Also add unit tests to exercise general ResolvePackageDependencies requirements. Fixes #28. To facilitate testing, make lockfile a field and provide constructors for dependency injection.

/cc @abpiskunov @eerhardt @dotnet/project-system

using Microsoft.Build.Utilities;
using NuGet.Configuration;
using NuGet.ProjectModel;
using System.Linq;

@abpiskunov abpiskunov Aug 29, 2016 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

System [](start = 6, length = 6)

sort usings #Resolved

@abpiskunov

abpiskunov commented Aug 29, 2016 •

Copy link
Copy Markdown
Contributor
        string packageId = $"{package.Name}/{package.Version.ToString()}";

what about $"{deps.Id}/{deps.VersionRange.MinVersion.ToString()}"; here too? #Resolved


Refers to: src/Tasks/Microsoft.NETCore.Build.Tasks/ResolvePackageDependencies.cs:321 in 39eea51. [](commit_id = 39eea51, deletion_comment = False)

var filePathList = fileGroup.GetFilePathListFor(package);
foreach (var filePath in filePathList)
{
if (Path.GetFileName(filePath) == "_._") continue;

@abpiskunov abpiskunov Aug 29, 2016 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continue [](start = 61, length = 8)

brackets around continue? #Resolved

@abpiskunov

abpiskunov commented Aug 29, 2016 •

Copy link
Copy Markdown
Contributor

using NuGet.Versioning;

add copyright #Resolved


Refers to: src/Tasks/Microsoft.NETCore.Build.Tasks.UnitTests/Mocks/MockPackageResolver.cs:1 in 39eea51. [](commit_id = 39eea51, deletion_comment = False)

[Theory]
[InlineData("dotnet.new")]
[InlineData("simple.dependencies")]
public void ItsAssignsValidParentTargetsAndPackages(string projectName)

@abpiskunov abpiskunov Aug 29, 2016 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ItsAssignsValidParentTargetsAndPackages [](start = 20, length = 39)

It #Resolved

{ MetadataKeys.ResolvedPath, "some resolved path" },
{ MetadataKeys.Type, "Unknown" },
{ MetadataKeys.Type, "AnalyzerAssembly" },
{ MetadataKeys.Analyzer, "true" },

@abpiskunov abpiskunov Aug 30, 2016 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ MetadataKeys.Analyzer, "true" }, [](start = 15, length = 39)

Remove this line #Resolved

@abpiskunov

abpiskunov commented Aug 30, 2016 •

Copy link
Copy Markdown
Contributor
        mockChildAnalyzerAssembly.SetMetadata(MetadataKeys.Analyzer, string.Empty);

Remove this line too #Resolved


Refers to: src/Tasks/Microsoft.NETCore.Build.Tasks.UnitTests/GivenThatWeWantToGetDependenciesViaDesignTimeBuild.cs:938 in 0701839. [](commit_id = 0701839, deletion_comment = False)

ReportException($"Lock file {ProjectLockFile} couldn't be found. Run a NuGet package restore to generate this file.");
}

_lockFile = new LockFileCache(BuildEngine4).GetLockFile(ProjectLockFile);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if ProjectLockFile is deleted between check and here? As general best practice, we should probably handle FileNotFoundException same as !File.Exists.

@natidea

natidea commented Aug 31, 2016

Copy link
Copy Markdown
Contributor Author

I'll go ahead and optimistically merge this in to unblock some customer demos this afternoon, but I'll keep taking feedback and open another PR shortly with more scenario tests (I'll keep #28 open to track this).

@natidea
natidea merged commit 123262b into dotnet:master Aug 31, 2016
@srivatsn

Copy link
Copy Markdown
Contributor

Modulo @abpiskunov's comments about the tests, the product changes look fine to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants