Skip to content
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

[Feature Request]: Warns a user if they use Restore as an explicit target (/t:Restore;Build) instead of the /restore flag #9690

Open
baronfel opened this issue Jan 29, 2024 · 2 comments
Labels
backlog Feature Request Feature: Warning Waves Warnings to enable in opt-in waves. Formerly "strict mode". Priority:2 Work that is important, but not critical for the release triaged

Comments

@baronfel
Copy link
Member

Summary

We should warn users when they use the Restore target specifically (-t:Restore) instead of /restore during a build - this is very often a mistake and we should point users to the correct version.

Background and Motivation

Users of the new CLI-based MSBuild property/item syntax often run into issues with uninitialized repositories, so they add -t:Restore and then wonder why their tooling only works after the first run. This is the core reason, and we should guide them to using the switch.

Proposed Feature

When

  • Restore is part of the targets list, and
  • a project contains NuGet packages, and
  • a nuget dependency file was created during the build
  • then issue a warning so the user knows they should use /restore instead of /t:Restore

Alternative Designs

No response

@baronfel baronfel added Feature Request needs-triage Have yet to determine what bucket this goes in. Feature: Warning Waves Warnings to enable in opt-in waves. Formerly "strict mode". labels Jan 29, 2024
@rainersigwald
Copy link
Member

This is in the description but to be super clear: running just /t:Restore is ok; the problem is when you /t:Restore;Build (or similar), because of XML caches that may give the Build part a stale view of NuGet-generated MSBuild targets files.

@baronfel baronfel changed the title [Feature Request]: Create an analyzer that warns for a user if they supply the Restore target as one of the explicit targets instead of the /restore flag [Feature Request]: Warns a user if they use Restore as an explicit target (/t:Restore;Build) instead of the /restore flag Jan 29, 2024
@AR-May AR-May added triaged backlog and removed needs-triage Have yet to determine what bucket this goes in. labels Jan 30, 2024
@rokonec rokonec added the Priority:2 Work that is important, but not critical for the release label Feb 1, 2024
@JanKrivanek
Copy link
Member

Related #9553
Pack is in the same boat here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Feature Request Feature: Warning Waves Warnings to enable in opt-in waves. Formerly "strict mode". Priority:2 Work that is important, but not critical for the release triaged
Projects
None yet
Development

No branches or pull requests

5 participants