-
Notifications
You must be signed in to change notification settings - Fork 694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for processing metaproj references from a solution file #1259
Conversation
{ | ||
// Log inputs | ||
var log = new MSBuildLogger(Log); | ||
log.LogDebug($"(in) ProjectReferences '{string.Join(";", ProjectReferences.Select(p => p.ItemSpec))}'"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can ItemSpec
be null or empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can't be null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then it's inconsistent with line 50 where you check the same value for null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It checks for empty also
@@ -0,0 +1,74 @@ | |||
using System; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to decide whether header is needed or not and be consistent about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove it from all files to reduce the daily overhead of this or automate it. Currently the tool from .NET that can do this doesn't work on PackageReference or project.json projects.
|
||
namespace NuGet.Build.Tasks | ||
{ | ||
public class GetRestoreSolutionProjectsTask : Task |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add xml-doc
|
||
// Filter obvious duplicates without considering OS case sensitivity. | ||
// This will be filtered further when creating the spec. | ||
var seen = new HashSet<string>(StringComparer.Ordinal); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Case-sensitive on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this can be cleaned up
// Filter obvious duplicates without considering OS case sensitivity. | ||
// This will be filtered further when creating the spec. | ||
var seen = new HashSet<string>(StringComparer.Ordinal); | ||
var parentDirectory = Path.GetDirectoryName(SolutionFilePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this fail if invalid string was provided for SolutionFilePath
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the path be relative?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is guaranteed to be the full path https://github.com/NuGet/NuGet.Client/blob/5fd37322b4f4c73b81b4c33b0c7628852e9da900/src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets#L156
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not guaranteed though the target won't change in future or this task won't be called from within different target. All inputs should be validated regardless.
|
||
foreach (var project in ProjectReferences) | ||
{ | ||
if (string.IsNullOrEmpty(project.ItemSpec)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it fail or warn on invalid value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should not be, but if it is the error/warning would be very unhelpful since it would not refer to anything. This protects against that.
continue; | ||
} | ||
|
||
var projectPath = Path.Combine(parentDirectory, project.ItemSpec); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normalize the path in case relative project path provided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update this, however the consumer of this is MSBuild which handles this fine internally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Address the feedback. Add unit-tests for new class.
5fd3732
to
c2d4353
Compare
public ITaskItem[] ProjectReferences { get; set; } | ||
|
||
/// <summary> | ||
/// Root project path used for resolving the absolute path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
root project path? or solution file path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Root metaproj from the solution.. I can make this more clear :)
if (projectPath.EndsWith(MetaProjExtension, StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
// Remove .metaproj from the path. | ||
projectPath = projectPath.Substring(0, projectPath.Length - MetaProjExtension.Length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you instead do Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file) )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did that initially but simplified to this. We know here exactly what needs to happen, an extra helper isn't needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either way would work fine though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd prefer being more verbose and call the helpers but your call.
In reply to: 107747427 [](ancestors = 107747427)
This change adds a task to modify project references coming from a solution file. When project build order is used the solution file read by restore contains links to .metaproj files instead of the actual projects. The actual project can be found by removing the metaproj extension. Cleaning up _SplitProjectReferencesByFileExistence, the outputs from this are not used since ProjectReference is used direcetly. There is no reason to depend on this external target. Fixes NuGet/Home#4869 Fixes NuGet/Home#4578
c2d4353
to
af6eff5
Compare
@alpaix unit tests are tracked in NuGet/Home#4875 |
👏 |
This change adds a task to modify project references coming from a solution file. When project build order is used the solution file read by restore contains links to .metaproj files instead of the actual projects. The actual project can be found by removing the metaproj extension.
Cleaning up _SplitProjectReferencesByFileExistence, the outputs from this are not used since ProjectReference is used direcetly. There is no reason to depend on this external target.
Fixes NuGet/Home#4869
Fixes NuGet/Home#4578
Tracking for the integration tests around this is here: NuGet/Home#4875 (post migration)