dotnet / project-system

The .NET Project System for Visual Studio
MIT License
969 stars 387 forks source link

Rebuild triggers DT-build #3039

Closed DevMatthias closed 6 years ago

DevMatthias commented 6 years ago

Is it regular behavior that a rebuild in VisualStudio is triggering a dt-build (designtime) at the same time.

Background is that we are using the CPS with MSBuild.Sdk.Extras to build Xamarin.Android projects and running into random fails on rebuild because VisualStudio starts a rebuild together with a dt-build. The builds access the same files and block each other out.

Pilchie commented 6 years ago

Can you tell us more about the projects you are using? Are they all SDK projects, or are some classic projects?

panopticoncentral commented 6 years ago

@DevMatthias can you add more information? We're investigating various performance issues related to design-time builds, but design-time builds explicitly shouldn't be running while a regular build is running. So if you're seeing that, it's likely a bug. Any extra help tracking this down would be helpful.

Pilchie commented 6 years ago

I think that MSBuild.Sdk.Extras implies SDK projects. @davkean mentioned that there was an issue where CPS would overlap design time and real builds. @lifengl - do you know if there is a CPS bug tracking that?

DevMatthias commented 6 years ago

Sorry bit longer christmas holiday.

We trying to use the CPS with the help of MSBuild.Sdk.Extras on android projects and that fails during rebuilds (I have a ticket open at Xamarin too). But I see the problem in a default .NETStandard project too.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
</Project>

I just issue a rebuild with the context menu and observe the build logging output with Project System Tools and I always see something like the following that seems like DT and Rebuild at the same time. image

lifengl commented 6 years ago

https://devdiv.visualstudio.com/DevDiv/_workitems/edit/554795 is tracking two builds at the same time.

DevMatthias commented 6 years ago

Is there any way for me to track that issue because I can't access the link above and always getting access denied with my MSDN account?

Pilchie commented 6 years ago

That's an internal issue in the closed source part of VS - unfortunately those bugs aren't accessible to the public, but hopefully @lifengl can update this on occasion too.

lifengl commented 6 years ago

We are investigating possible work here. In the old csproj, when DT build is in-proc, there is no way it can happen at the same time as the real build. The out of proc DT build happened also to be used to resolve some dead locks issues (C++?), when a UI thread blocking call want to retrieve result from a DT build, and the solution build will not finish when a such blocking call is not finished, so by disabling DT build to run when a real build is running, we may lead into dead locks in the product. DT build is mostly to do some in-memory computations, but it is somewhat out of control, and executes too much real build logic, including touching file systems.

lifengl commented 6 years ago

I think we have two problems here. One is that we don't have infrastructure to block DT build to run at the same time as the real build is running. This is also needed to be addressed in the DTBB side as well. On the other side, there is no reason to trigger the design time build in every rebuild. The problem here is that the project.assert.json watcher triggers the project to dirty twice, and force the entire project state to be refreshed twice. This alone is a performance problem in this scenario. The file watcher need prevent to reset the project state, if NuGet restore doesn't change the project. Is this a known issue related to the NuGet behavior? @Pilchie , will NuGet's fix not to touch address this problem? (In which case, we should not run DT build at all in this scenario.)

lifengl commented 6 years ago

link to a related fix inside the json file watcher

DevMatthias commented 6 years ago

I have just tried the VisualStudio 15.7.0 Preview and the DT-builds are gone on rebuild and I guess the issue is fixed.