-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[Bug]: MSBuild should not embed project extensions during restore #9512
Description
Issue Description
During restore, any generated file in $(MSBuildProjectExtensionsPath) is imported here and here. Imports are automatically embedded in the binary log but in the case of these files, they are generated by the restore gesture.
When a user specifies /Target:Restore or /Restore, MSBuild launches a build invocation of the Restore target with a special global property MSBuildRestoreSessionId. It should also set ImportProjectExtensionProps and ImportProjectExtensionTargets to false to skip the import of any project extension during restore. This would only break users who are doing the following:
- Invoke some custom build target that generates files in
$(MSBuildProjectExtensionsPath) - Invoke restore and expect their generated props and targets to affect Restore
I am not aware of anyone doing this so I don't think it would be a breaking change. At this time, since the files are embedded during evaluation, the ones that get embedded are not guaranteed to be correct if restore writes new versions. The functionality that executes restore (like NuGet) should embed these files instead.
I'd be more than happy to send the pull request.
Steps to Reproduce
- Restore a project with the binary logger (
/t:restore /bl) - Modify a package reference
- Restore again
Expected Behavior
The binary log should have a the updated .nuget.g.props
Actual Behavior
The embedded .nuget.g.props in the binary log is the one that existed on disk when the project was evaluated not the one that was generated during restore.
Analysis
No response
Versions & Configurations
No response