dotnet / project-system

The .NET Project System for Visual Studio
MIT License
967 stars 386 forks source link

Issue with building ASP.Net Core projects quickly after loading #3550

Open rakatyal opened 6 years ago

rakatyal commented 6 years ago

I am seeing an issue with our automated tests where sometimes the test projects we create (ASP.Net Core MVC Application) fail to build with the attached error:

capture

I am also able to repro this on a new project with the MVC template if I build the solution very quickly right after loading the solution. Note that the solution builds fine on retrying or after waiting a while.

Looks like the build is not waiting for the restore to finish.

jviau commented 6 years ago

A very similar issue: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/615683

  1. New .netcore ConsoleAp
  2. Edit csproj
  3. Change netcoreapp2.0 to netcoreapp2.1
  4. Ctrl+Shift+B (save and build), get error (expected)
  5. Change netcoreapp.2.1 to netcoreapp2.0
  6. Ctrl+Shift+B (save and build)

Expected: No error

Actual: Error

Error: Assets file 'C:\Users\javia\source\repos\ConsoleApp5\ConsoleApp5\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.0'. Ensure that restore has run and that you have included 'netcoreapp2.0' in the TargetFrameworks for your project.

Build needs to be blocked while nuget restore is ongoing.

Pilchie commented 6 years ago

@davkean - you said you understand this issue. Can you describe an approach for how to fix it for @jmarolf ?

davkean commented 6 years ago

I expect there's two issues;

In the first case, we're not getting initialized or data faster enough from design-time build to block build. We only block build after we get data from design-time build. In the second case, we're not getting called back quick enough to block the build until we've processed the change. I suspect we'd need to block the build after the project file has changed but before we've processed the change.

jviau commented 6 years ago

FYI, there is a feedback issue regarding this. https://developercommunity.visualstudio.com/content/problem/250035/new-project-system-does-not-update-state-appropria.html

JVimes commented 6 years ago

Happens for simple .NET Framework projects, too. Why not default the build command to "disabled", enable once dependent features are available?