-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fail Restore when an SDK is unresolved or entry target does not exist #6312
Conversation
…arget like Restore doesn't exist Fixes dotnet#6281
ba5e258
to
dd7831c
Compare
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 good! Seems like there was no easy way to pass the entrypoint target(s) through to here?
Sort of, in this context
Which is why I'm checking if the target that doesn't exist is in that list, this tells us if a top level target isn't there which should fail the build in this context. Other targets like InitialTargets and Before/AfterTargets to be built are passed in as So the original |
Oh, I think I misunderstood that part, then. So did you add the new BuildRequestDataFlag in case that part fails? Looking more closely at it, it seems to log a message if (a particular target isn't in the list and the SkipNonexistentTopLevelTargets flag is set) or (the target is missing, and another flag is set). Otherwise, it adds it as if it's present. How is the error fitting in? Also, is that right? I would imagine something more like: Also, as a nit, HasFlag is slow. Not that big a deal, but I thought I should mention it. |
1936bff
to
9a23e41
Compare
@Forgind I've updated the PR to address the issue you pointed out and added a unit test for it as well. I'm going to leave |
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 good! I tried to think of cases in which this would fail but didn't come up with any, and your explanation helped me properly understand that if clause. Thanks!
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Add the behavior improvements from dotnet#6312 to the 16.10 changewave since they cause failures in cases that didn't fail before.
Add the behavior improvements from dotnet#6312 to the 16.10 changewave since they cause failures in cases that didn't fail before.
#6312 made (good, IMO) changes to the behavior of -restore and -t:restore invocations of MSBuild in malformed projects. Since these are new errors, though, the new behavior might fail passing builds. So put it behind a change wave Just In Case.
Add the behavior improvements from dotnet#6312 to the 16.10 changewave since they cause failures in cases that didn't fail before.
Reverts dotnet#6312 and dotnet#6372. SHAs reverted: 29dc5e1 and da900e2 respectively.
Maximal subset of dotnet#6312 and dotnet#6372. Also removes an unnecessary test per dotnet#6430 (comment)
Maximal subset of dotnet#6312 and dotnet#6372. Also removes an unnecessary test per dotnet#6430 (comment)
Reverts dotnet#6312 and dotnet#6372. SHAs reverted: 29dc5e1 and da900e2 respectively.
Maximal subset of dotnet#6312 and dotnet#6372. Also removes an unnecessary test per dotnet#6430 (comment)
Fixes #6281
Context
BuildRequestDataFlags
andProjectLoadSettings
are set during/t:restore
in a best effort to run the Restore target in hopes that it will correct the potentially bad state that a project is in. Visual Studio also setsProjectLoadSettings.IgnoreMissingImports
so that an unresolved MSBuild project SDK doesn't prevent loading of a bad project so it can give the user an error and let them edit the file.However, this means that from the command-line an unresolved SDK doesn't fail
/t:restore
. This is because the missing "import" is ignored and non-existent targets are ignored so the build succeeds.Changes Made
Introduced two new
BuildRequestDataFlags
:SkipNonexistentNonTopLevelTargets
- A new flag to be used in this context to tell the build to ignore non-existent targets but not top level ones. In this case we're specifying/t:restore
so if the Restore target doesn't exist, that should be an error. Only other targets that are trying to run are ignored (like InitialTargets, Before/AfterTargets, etc).FailOnUnresolvedSdk
- We still need to ignore missing imports and I can't introduce a new flag to split the implementation now since Visual Studio setsProjectLoadSettings.IgnoreMissingImports
as a way to ignore unresolved SDKs. So this flag tells the evaluator to fail on an unresolved SDK but to continue ignoring other missing imports.Testing
Added three new unit tests: