question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

See https://github.com/dotnet/cli/pull/9117 and https://github.com/dotnet/sdk/pull/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

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:15 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
NickCravercommented, Apr 21, 2018

For what it’s worth, this would break many of our builds running fine today. It is incorrect to say it’ll only fail on the first attempt. A good build on a build agent should be doing a clean build on every pass, and therefore will fail on every attempt.

I definitely disagree with breaking this behavior that works for many people today. They have no idea they shouldn’t do it because it works. I get that it may break some situations, but I think you’ll quickly find this is used more than is probably currently thought. I’ve seen it a lot of places not related to us while figuring out how to do various things with builds along the way with SDK projects.

If it helps, the general procedure that I see lead to this is “what does Visual Studio do?”, “Oh, it just restores first…I’ll do that, Restore;Build”.

1reaction
m0sacommented, Dec 6, 2019

This should be a hard error in msbuild.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NuGet pack and restore as MSBuild targets
Specifies that pack should not run package analysis after building the package. MinClientVersion, Specifies the minimum version of the NuGet ...
Read more >
The SDK 'Microsoft.NET.Sdk' specified could not be found - ...
Net Core 2.0 installation and seemingly messing it up. I would get this same error for dotnet restore , dotnet build or dotnet...
Read more >
Build programs with Bazel
To run Bazel, go to your base workspace directory or any of its subdirectories and type ... See build if you need to...
Read more >
GNU make
GNU make. This file documents the GNU make utility, which determines automatically which pieces of a large program need to be recompiled, ...
Read more >
Using Amazon CloudWatch alarms
Create a CloudWatch alarm that sends an Amazon SNS message or performs an action when the alarm changes state.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found