Skip to content
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

Building a subset of a VS solution at the command line causes MSB4057 #6465

Merged
merged 3 commits into from
May 20, 2021

Conversation

Forgind
Copy link
Member

@Forgind Forgind commented May 19, 2021

Fixes #6373

Summary

Solution metaprojects should have a target for each project they contain, so that you can build a single project or set of projects in the context of the solution. A regression in 16.10 means that instead, specifying a project name as a target when building a solution attempts to build a target with that name for every project in the solution.

Customer impact

Customers cannot build a subset of a solution by specifying a project between #6282 and this PR.

Regression?

Yes, from 16.9. This bug was introduced in #6282. The critical line is line 786 of SolutionProjectGenerator, though all similar instances were reverted in this case. Note that as #6282 is an agglomeration of functionally unrelated changes, no other files in #6282 relied on the changes in SolutionProjectGenerator.

Changes Made

Reverted the part of #6282 using Except incorrectly, i.e., the part in SolutionProjectGenerator, and added a test.

Testing

Created a unit test that fails before the other changes in this PR and succeeds afterwards. The unit test mimics but simplifies the customer's repro.

Risk

Low. Revert to prior implementation.

@Forgind Forgind changed the base branch from main to vs16.10 May 19, 2021 23:02
@@ -782,7 +782,7 @@ private void EvaluateAndAddProjects(List<ProjectInSolution> projectsInOrder, Lis
AddTraversalTargetForProject(traversalInstance, project, projectConfiguration, "Publish", null, canBuildDirectly);

// Add any other targets specified by the user that were not already added
foreach (string targetName in _targetNames.Except(traversalInstance.Targets.Keys, StringComparer.OrdinalIgnoreCase))
foreach (string targetName in _targetNames.Where(i => !traversalInstance.Targets.ContainsKey(i)))
Copy link
Member

Choose a reason for hiding this comment

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

Should we extract method that returns the enumerable? And use it in four places? And add a detailed comment explaining that it has to be lazy because evidently the traversalInstance.Targets contents changes during enumeration? It's a tricky spot.

Copy link
Member

Choose a reason for hiding this comment

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

also need to pay attention to how Keys behaves - is it returning the live collection or a snapshot of the keys?

Copy link
Member

Choose a reason for hiding this comment

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

Extract method might be dicey - maybe better keep as is for simplicity... just add comments? You decide

Copy link
Member Author

Choose a reason for hiding this comment

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

I want this to be as small of a change and as safe of a change as possible, since this is going into 16.10 rather than 17.0. This is a straight revert of the relevant part of the commit that caused the issue, which is safest in my opinion. Adding a comment is a good plan, though—I'll just add it for the first case, since that's the only one that I know should be just in time.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed on keeping this to a revert. Can extract as follow up in a future milestone if that's better.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, let’s not extract, it was just a knee jerk reaction of seeing the changes in four places. All good!

Forgind added 2 commits May 19, 2021 16:41
Exclude takes a snapshot of what we're excluding. We change the Enumerable mid-enumeration, which makes that invalid.
@Forgind Forgind force-pushed the fix-except-cache-problem branch from 2491470 to 94ce625 Compare May 19, 2021 23:41
@rainersigwald rainersigwald changed the title Fix except cache problem Building a subset of a VS solution at the command line causes MSB4057 May 20, 2021
@rainersigwald rainersigwald force-pushed the fix-except-cache-problem branch from e32bd4c to d6a27dd Compare May 20, 2021 19:21
@rainersigwald rainersigwald merged commit 2fd48ab into dotnet:vs16.10 May 20, 2021
@Forgind Forgind deleted the fix-except-cache-problem branch May 20, 2021 20:01
targos added a commit to targos/node that referenced this pull request May 31, 2021
This allows to build Node.js at the (temporary) cost of longer build
times.

Refs: nodejs#38872
Refs: https://github.com/dotnet/msbuild/releases/tag/v16.10.0
Refs: dotnet/msbuild#6465
Refs: dotnet/msbuild#6373
@elikrief
Copy link

it seems that using the "rebuild" switch is working as a workaround

msbuild solution.sln -t project:rebuild

aduh95 pushed a commit to targos/node that referenced this pull request May 31, 2021
This allows to build Node.js at the (temporary) cost of longer build
times.

Refs: nodejs#38872
Refs: https://github.com/dotnet/msbuild/releases/tag/v16.10.0
Refs: dotnet/msbuild#6465
Refs: dotnet/msbuild#6373

PR-URL: nodejs#38873
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
danielleadams pushed a commit to nodejs/node that referenced this pull request Jun 1, 2021
This allows to build Node.js at the (temporary) cost of longer build
times.

Refs: #38872
Refs: https://github.com/dotnet/msbuild/releases/tag/v16.10.0
Refs: dotnet/msbuild#6465
Refs: dotnet/msbuild#6373

PR-URL: #38873
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
@ben-may
Copy link

ben-may commented Jun 2, 2021

Will this be released in 16.10.1? We have tests and things that are hitting this bug.
Thanks!

@rainersigwald
Copy link
Member

@ben-may Yes, it's in the internal builds and will be in the public 16.10.1.

@ben-may
Copy link

ben-may commented Jun 2, 2021

Thanks!

targos added a commit to nodejs/node that referenced this pull request Jun 5, 2021
This allows to build Node.js at the (temporary) cost of longer build
times.

Refs: #38872
Refs: https://github.com/dotnet/msbuild/releases/tag/v16.10.0
Refs: dotnet/msbuild#6465
Refs: dotnet/msbuild#6373

PR-URL: #38873
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
targos added a commit to nodejs/node that referenced this pull request Jun 5, 2021
This allows to build Node.js at the (temporary) cost of longer build
times.

Refs: #38872
Refs: https://github.com/dotnet/msbuild/releases/tag/v16.10.0
Refs: dotnet/msbuild#6465
Refs: dotnet/msbuild#6373

PR-URL: #38873
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
targos added a commit to nodejs/node that referenced this pull request Jun 5, 2021
This allows to build Node.js at the (temporary) cost of longer build
times.

Refs: #38872
Refs: https://github.com/dotnet/msbuild/releases/tag/v16.10.0
Refs: dotnet/msbuild#6465
Refs: dotnet/msbuild#6373

PR-URL: #38873
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
@john-hynes
Copy link

john-hynes commented Jun 8, 2021

We've hit this issue with Pipeline builds in Azure DevOps as you've updated your build agents. When will the fix be deployed to Azure?

targos added a commit to nodejs/node that referenced this pull request Jun 11, 2021
This allows to build Node.js at the (temporary) cost of longer build
times.

Refs: #38872
Refs: https://github.com/dotnet/msbuild/releases/tag/v16.10.0
Refs: dotnet/msbuild#6465
Refs: dotnet/msbuild#6373

PR-URL: #38873
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Building a VS solution file at the command line now causes MSB4057
7 participants