-
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
Do not import project extensions during restore #9748
Conversation
FYI @KirillOsenkov |
Co-authored-by: Rainer Sigwald <raines@microsoft.com>
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 great. I guess adding more special-case handling of the restore
target should boost the priority of #9553.
100% agree on we should add mechanism flagging that issue. |
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.
Thank you!
I wonder if in this case we could get away with adding a high-importance message right to |
I support that! It wouldn't catch the case of restore run requested via dependencies definition - but I'd hope it's rather esoteric. And even if it wouldn't be esoteric - check in XMake is cheap and we can have it quickly... - do you want to shoot a PR? :-) |
Wait, I don't think I understand what the message is for? Is it "you're running Restore and something else in the same invocation"? |
Yes, it would basically warn against |
I fear that's the same kind of "breaking change" we've had to back out before. I think the analyzer-related "have a way to opt into new warnings" would have to be in place first. |
Question for everyone: Should this pull request also set |
I'd leave that definition in the SDK I think. |
Hi @jeffkl, These changes backfired in an unusual way for the tests in sdk (e.g. dotnet/sdk#39093) In the test, publish and restore are run on the same project separately, and on restore execution PublishTrimmed switch is passed in a special way Since restore happens after publish, project is considered as up to date and this stage is skipped: As a possible strategies we can suggest:
Please share you opinion on that! |
also adding @Forgind for his insights |
If my understanding is correct, we should update the tests to account for the new behavior. I've filed an issue here and added some details: |
jeffkl and I investigated this yesterday in the SDK insertion PR and found the same root cause as YuliiaKovalova. We also decided it's probably best to just update the tests. We're still talking a bit (with dsplaisted) about how big of a breaking change it likely is and what we should do about it. Thanks for the parallel investigation! |
Even switching to inline argument will help! But I though it was intentionally passed this way for checking some specific scenario which I am not aware of. |
I was trying to understand how I'm related to this since I don't even know what this is. Took me a second as I looked at the blame on the file, and I'm not in the blame. However, I'm in the commit history for the file because I moved every test in the repo in this PR. So, I'd just recommend looking at the blame history over the commit history since it usually gives you a more accurate gauge of the people involved. |
Fixes #9512
Context
During restore, MSBuild needs to evaluate the entry project and during this evaluation if any of the project extension files that NuGet generates (
project.nuget.g.props
andproject.nuget.g.targets
) they are used during the next restore. Another side effect is the files that exist on disk at the beginning of restore are embedded in the binary log and not the ones that are generated by NuGet.Changes Made
Introduced a new property
MSBuildIsRestoring
which is set during an implicit restore (/restore
) or an explicit restore (/Target:restore
) so that we don't need to take a dependency onMSBuildRestoreSessionId
. This is now a property users can key off of to detect if a command-line based restore is running.Default
ImportProjectExtensionProps
andImportProjectExtensionTargets
tofalse
ifMSBuildIsRestoring
istrue
unless a users has explicitly setImportProjectExtensionProps
orImportProjectExtensionTargets
totrue
. This allows users to bring back the old behavior if desired.I also added
MSBuildRestoreSessionId
andMSBuildIsRestoring
toMSBuildConstants
so their names can be defined in a single place.Testing
Added to existing unit tests to verify
ImportProjectExtensionProps
andImportProjectExtensionTargets
default tofalse
ifMSBuildIsRestoring
istrue
ImportProjectExtensionProps
andImportProjectExtensionTargets
are set totrue
, their values are not set even ifMSBuildIsRestoring
istrue
Notes