Skip to content

[Bug]: MSBuild should not embed project extensions during restore #9512

@jeffkl

Description

@jeffkl

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:

  1. Invoke some custom build target that generates files in $(MSBuildProjectExtensionsPath)
  2. 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

  1. Restore a project with the binary logger (/t:restore /bl)
  2. Modify a package reference
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Functionality:RestorePriority:2Work that is important, but not critical for the releasebacklogbughelp wantedIssues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim.triaged

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions