3

I'm building a solution containing .NET Standard 2.0 and .NET Core 2.0 projects (C# and F#) in VS2019 (16.1.1). If I build multiple times without changes the second and subsequent builds should say "Build: 0 succeeded, 0 failed, X up-to-date", but it sometimes rebuilds some projects every time. How do I find out exactly why?

There are many SO questions and blog posts about this, most of them suggesting setting the build log verbosity to "Diagnostic" and looking for "not up to date". I've done that and the string is not found, nor is "not up-to-date" (but "up-to-date" occurs many times). So this appears to have changed in VS2019. I also know about the U2DCheckVerbosity registry setting, but that's only for .NET Framework. Reading through the build log output is unrealistic, as it's over 360 thousands lines, so I need to know what to search for.

Please note, I'm not looking for guesses as to what the problem might be - I'm looking for a way to get VS/the compiler to tell me.

EM0
  • 5,369
  • 7
  • 51
  • 85
  • No need to set the verbosity to Diagnostic, instead set it to detailed to find the out of date resources. – C.J. Jul 22 '19 at 15:44
  • Hi Em0, any update for this issue? Have you checked if those option can work to resolve the unexpected rebuild:) – LoLance Jul 29 '19 at 05:31
  • Hi @LanceLi-MSFT, I haven't had that specific issue come up again since. Will update this when it (or something similar) inevitably happens. – EM0 Jul 29 '19 at 11:59
  • Sure, we'll archive it. Any update feel free to share here. – LoLance Aug 07 '19 at 07:37

3 Answers3

5

I'm looking for a way to get VS/the compiler to tell me. (For VS2019)

It's hard to reproduce same issue so I'm not sure about the cause of your issue. But as for what you're asking is the way to find up-to-date related info in Output window, maybe you can check the Up To Data Checks option for .net core.

Go Tools=>Options=>Projects and Solutions=>.net core=>Up To Data Checks. Make sure you've checked the Don't call MSBuild if a project appears to be up-to-date. Then change the Logging Level to Info or Verbose.(Choose the suitable level according to your needs)

For the normal .net framework projects or C++ projects, the build output verbosity in build and run would be of great help. But when trying to find the reason why VS consider one .net core or .net standard project is out-of-date, I think we can try this option since its output is more clear.

E.g: (One .net Core project which depends on the Standard project with Info level .net core Up-To-Date Check):

enter image description here

And if you have too many projects in one solution, I suggest you build one project one time instead of build the whole solution so you can locate the cause of the rebuild more easily.

LoLance
  • 25,666
  • 1
  • 39
  • 73
  • Thanks, that looks like just what I'm looking for. I can't repro the original issue right now, but it happened with another project and setting Log Level = INFO identified that it had some files set to "Copy always". I'll try this again when the original issue pops up again. – EM0 Jul 23 '19 at 09:24
  • @EM0 Glad to know it makes some help:) – LoLance Jul 23 '19 at 09:27
  • 2
    This answer helped me finding SDK-Style Projects -> Up to Date checks in VS2019. Thanks! – Marcin Zawiejski Apr 30 '20 at 12:57
1

VS writes a file called NETCoreApp,Version=v2.0.AssemblyAttributes.cs into temp folder. If you build several .net core projects, the file gets changed by the other project and your VS thinks the old project is modified and builds it.

Move the generated files into the project to reduce the builds:

<PropertyGroup>
    <TargetFrameworkMonikerAssemblyAttributesFileClean>False</TargetFrameworkMonikerAssemblyAttributesFileClean>
    <TargetFrameworkMonikerAssemblyAttributesPath>$(MSBuildThisFileDirectory)SharedAssemblyAttributes.cs</TargetFrameworkMonikerAssemblyAttributesPath>
</PropertyGroup>
magicandre1981
  • 27,895
  • 5
  • 86
  • 127
1

In VS2019 the option to control logging is:

enter image description here

The default is "None", but honestly "Minimal" is a good setting in general. When set to that level, only a single line is output per project, and only if that project is not up-to-date. That line will explain exactly why the project is considered out-of-date.

It's worth remembering that this is Visual Studio's up-to-date check, which it uses to quickly assess project state and avoid the comparatively expensive call to MSBuild. It is possible, with exotic project configurations, that VS determines your project needs building, but MSBuild doesn't actually build. This is rare, but can be worth understanding if you're debugging issues here.

Drew Noakes
  • 300,895
  • 165
  • 679
  • 742