-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Graph: Mimic quirk for sln-based builds with target name containing semicolon #9390
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
Closed
dfederm
wants to merge
3
commits into
dotnet:main
from
dfederm:dfederm/fix-graph-sln-semicolon-targets
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -56,9 +56,11 @@ public delegate ProjectInstance ProjectInstanceFactoryFunc( | |||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
private readonly Lazy<IReadOnlyCollection<ProjectGraphNode>> _projectNodesTopologicallySorted; | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
private GraphBuilder.GraphEdges Edges { get; } | ||||||||||||||||||||||||||||||||||||
private readonly bool _isSolution; | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
internal GraphBuilder.GraphEdges TestOnly_Edges => Edges; | ||||||||||||||||||||||||||||||||||||
private readonly GraphBuilder.GraphEdges _edges; | ||||||||||||||||||||||||||||||||||||
dfederm marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
internal GraphBuilder.GraphEdges TestOnly_Edges => _edges; | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
public GraphConstructionMetrics ConstructionMetrics { get; private set; } | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
@@ -432,7 +434,8 @@ public ProjectGraph( | |||||||||||||||||||||||||||||||||||
EntryPointNodes = graphBuilder.EntryPointNodes; | ||||||||||||||||||||||||||||||||||||
GraphRoots = graphBuilder.RootNodes; | ||||||||||||||||||||||||||||||||||||
ProjectNodes = graphBuilder.ProjectNodes; | ||||||||||||||||||||||||||||||||||||
Edges = graphBuilder.Edges; | ||||||||||||||||||||||||||||||||||||
_edges = graphBuilder.Edges; | ||||||||||||||||||||||||||||||||||||
_isSolution = graphBuilder.IsSolution; | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
_projectNodesTopologicallySorted = new Lazy<IReadOnlyCollection<ProjectGraphNode>>(() => TopologicalSort(GraphRoots, ProjectNodes)); | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
@@ -472,7 +475,7 @@ GraphConstructionMetrics EndMeasurement() | |||||||||||||||||||||||||||||||||||
return new GraphConstructionMetrics( | ||||||||||||||||||||||||||||||||||||
measurementInfo.Timer.Elapsed, | ||||||||||||||||||||||||||||||||||||
ProjectNodes.Count, | ||||||||||||||||||||||||||||||||||||
Edges.Count); | ||||||||||||||||||||||||||||||||||||
_edges.Count); | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
@@ -598,6 +601,24 @@ public IReadOnlyDictionary<ProjectGraphNode, ImmutableList<string>> GetTargetLis | |||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||
ThrowOnEmptyTargetNames(entryProjectTargets); | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
// Solutions have quirky behavior when provided a target with ';' in it, eg "Clean;Build". This can happen if via the command-line the user provides something | ||||||||||||||||||||||||||||||||||||
// like /t:"Clean;Build". When building a project, the target named "Clean;Build" is executed (which usually doesn't exist, but could). However, for solutions | ||||||||||||||||||||||||||||||||||||
// the generated metaproject ends up calling the MSBuild task with the provided targets, which ends up splitting the value as if it were [ "Clean", "Build" ]. | ||||||||||||||||||||||||||||||||||||
// Mimic this flattening behavior for consistency. | ||||||||||||||||||||||||||||||||||||
if (_isSolution && entryProjectTargets != null && entryProjectTargets.Count != 0) | ||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||
List<string> newEntryTargets = new(entryProjectTargets.Count); | ||||||||||||||||||||||||||||||||||||
foreach (string entryTarget in entryProjectTargets) | ||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||
foreach (string s in ExpressionShredder.SplitSemiColonSeparatedList(entryTarget)) | ||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||
newEntryTargets.Add(s); | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
entryProjectTargets = newEntryTargets; | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
Comment on lines
+609
to
+620
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why recreating the list twice? (
Suggested change
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
// Seed the dictionary with empty lists for every node. In this particular case though an empty list means "build nothing" rather than "default targets". | ||||||||||||||||||||||||||||||||||||
var targetLists = ProjectNodes.ToDictionary(node => node, node => ImmutableList<string>.Empty); | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
@@ -606,10 +627,10 @@ public IReadOnlyDictionary<ProjectGraphNode, ImmutableList<string>> GetTargetLis | |||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
foreach (ProjectGraphNode entryPointNode in EntryPointNodes) | ||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||
var entryTargets = entryProjectTargets == null || entryProjectTargets.Count == 0 | ||||||||||||||||||||||||||||||||||||
ImmutableList<string> nodeEntryTargets = entryProjectTargets == null || entryProjectTargets.Count == 0 | ||||||||||||||||||||||||||||||||||||
? ImmutableList.CreateRange(entryPointNode.ProjectInstance.DefaultTargets) | ||||||||||||||||||||||||||||||||||||
: ImmutableList.CreateRange(entryProjectTargets); | ||||||||||||||||||||||||||||||||||||
var entryEdge = new ProjectGraphBuildRequest(entryPointNode, entryTargets); | ||||||||||||||||||||||||||||||||||||
var entryEdge = new ProjectGraphBuildRequest(entryPointNode, nodeEntryTargets); | ||||||||||||||||||||||||||||||||||||
encounteredEdges.Add(entryEdge); | ||||||||||||||||||||||||||||||||||||
edgesToVisit.Enqueue(entryEdge); | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
@@ -645,7 +666,7 @@ public IReadOnlyDictionary<ProjectGraphNode, ImmutableList<string>> GetTargetLis | |||||||||||||||||||||||||||||||||||
var expandedTargets = ExpandDefaultTargets( | ||||||||||||||||||||||||||||||||||||
applicableTargets, | ||||||||||||||||||||||||||||||||||||
referenceNode.ProjectInstance.DefaultTargets, | ||||||||||||||||||||||||||||||||||||
Edges[(node, referenceNode)]); | ||||||||||||||||||||||||||||||||||||
_edges[(node, referenceNode)]); | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
var projectReferenceEdge = new ProjectGraphBuildRequest( | ||||||||||||||||||||||||||||||||||||
referenceNode, | ||||||||||||||||||||||||||||||||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.