Skip to content

We should generate an error or warning if Restore and Build targets are run in the same evaluation #2170

Open
@nguerrera

Description

@nguerrera

See dotnet/cli#9117 and #2010

It has always been incorrect in general to to msbuild /t:restore;build or <MSBuild Targets="Restore;Build" because evaluation is shared and so build doesn't see the targets pulled down from nuget. #2010 adds a hard dependency on the ProjectAssetsFile being set by the generated props file in restore, which means that the first run of these incorrect patterns will always fail now instead of sometimes getting lucky. Note that lucky could be silent bad behavior.

Options I see:

  1. Improve the error message to hint that the cause of the error may be that restore and build were attempted in the same evaluation.
  2. Improve the message and also downgrade it to a warning.
  3. Revert the change.

I would like to do (1) because we've lost a lot of time debugging subtly broken builds with this incorrect pattern, but we should think carefully about it.

cc @livarcocc @dsplaisted @wli3 @rrelyea @rohit21agrawal @nkolev92

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions