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
@@ -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)))

This comment has been minimized.

@KirillOsenkov

KirillOsenkov May 19, 2021
Member

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.

This comment has been minimized.

@KirillOsenkov

KirillOsenkov May 19, 2021
Member

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

This comment has been minimized.

@KirillOsenkov

KirillOsenkov May 19, 2021
Member

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

This comment has been minimized.

@Forgind

Forgind May 19, 2021
Author Member

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.

This comment has been minimized.

@rainersigwald

rainersigwald May 20, 2021
Contributor

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

This comment has been minimized.

@KirillOsenkov

KirillOsenkov May 20, 2021
Member

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
Exclude takes a snapshot of what we're excluding. We change the Enumerable mid-enumeration, which makes that invalid.
@Forgind Forgind force-pushed the Forgind:fix-except-cache-problem branch from 2491470 to 94ce625 May 19, 2021
@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 Forgind:fix-except-cache-problem branch from e32bd4c to d6a27dd May 20, 2021
@rainersigwald rainersigwald merged commit 2fd48ab into dotnet:vs16.10 May 20, 2021
7 checks passed
7 checks passed
license/cla All CLA requirements met.
Details
@azure-pipelines
msbuild-pr Build #20210520.4 succeeded
Details
@azure-pipelines
msbuild-pr (Linux Core) Linux Core succeeded
Details
@azure-pipelines
msbuild-pr (Windows Core) Windows Core succeeded
Details
@azure-pipelines
msbuild-pr (Windows Full Release (no bootstrap)) Windows Full Release (no bootstrap) succeeded
Details
@azure-pipelines
msbuild-pr (Windows Full) Windows Full succeeded
Details
@azure-pipelines
msbuild-pr (macOS Core) macOS Core succeeded
Details
@Forgind Forgind deleted the Forgind:fix-except-cache-problem branch May 20, 2021
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

@elikrief elikrief commented May 31, 2021

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

msbuild solution.sln -t project:rebuild

aduh95 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

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 added 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 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
Contributor

@rainersigwald rainersigwald commented Jun 2, 2021

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

@ben-may
Copy link

@ben-may 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 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
Linked issues

Successfully merging this pull request may close these issues.

7 participants