Update 1 April 2020: VS 2019 V16.5.2 has been released, and it does appear to fix both problems reported in this post.
TL;DR DO NOT update VS 2019 beyond 16.4.0, or you risk breaking the WDK, to the point that it won’t compile anything when Code Analysis is enabled (and you can’t subsequently turn off Code Analysis).
If you’re like most people, when Visual Studio lights the little “there’s an update available” icon, you get the update installed as soon as convenient. After all, these updates (which seem to come out ever other week or so) often fix real (annoying) problems in Visual Studio. So, most of us figure, better to get them installed and see what gets fixed.
Except we now know, with Visual Studio (VS) as with Windows Update, not every update always brings good news. And so it is with VS 16.4.x.
If you enable Code Analysis (CA) on the broken versions of VS, and you try to build a driver, you’ll be treated to the following error:
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\km\ntddk.h(19206,1): fatal error C1001:
Internal compiler error.
1>(compiler file 'msc1.cpp', line 1532)
1> To work around this problem, try simplifying or changing the program near the locations listed above.
1>If possible please provide a repro here: https://developercommunity.visualstudio.com
What’s worse, is that when you get this problem, you’re not able to effectively disable Code Analysis. That is, even when you disable Code Analysis in the project properties, you will still find a line like the following in your VCXPROJ file:
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<ClCompile>
<EnablePREfast>true</EnablePREfast>
</ClCompile>
</ItemDefinitionGroup>
You can manually disable Code Analysis by changing “true” above to “false” (or just by deleting the <EnablePREfast> property entirely.
You don’t need much of a driver to repro this problem. The following will demonstrate the error:
#include <ntddk.h> extern "C" NTSTATUS DriverEntry( PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) { UNREFERENCED_PARAMETER(DriverObject); UNREFERENCED_PARAMETER(RegistryPath); return STATUS_SUCCESS; }
Here at OSR we noticed the problem in VS 2019 V16.5.1, but we’ve heard that problems have been seen all the way back to updates before 16.5.
The Microsoft WDK team is aware of the problem and is working with the VS team to get the issue addressed just as soon as they can.
We’re hoping for a fix for this as soon as V16.5.2 — Cross your fingers!
In the meantime, you might want to delay your VS updates until you confirm that the problem is fixed.
If you’re reading this “too late” and you’ve already updated (or, you discover this problem like we did at OSR: You’re setting up a new system for working at home, and you download “the latest”)… the good news is that you can remove VS and reinstall an older version. See this link for where to download and install an older version of VS 2019.