I was unsuccessful with the two answers provided by Matthijs and Nicole Calinoiu, but after further investigation, I stumbled across this question on StackOverflow.
In short, it is not recommended one disable these files from being outputted in general. According to seva titov's answer in that question linked above:
First, removing .lastcodeanalysissucceededd will cause code analysis re-run even when nothing has changed. Second, removing .CodeAnalysisLog.xml will make it almost impossible to investigate details of analysis errors and warnings. So you might as well just turn off the code analysis for the project.
Therefore, it is best to just move these two files to the intermediate file location. This location is where all the *.obj
files, *.log
files, and other meta files exist. To do this, right click your project and click "Unload Project."

Then, right click the project and click Edit p͟r͟o͟j͟e͟c͟t͟.vcxproj
. In the picture, I click Edit Test1.vcxproj
, because my project for this demonstration is called Test1
:

And then, at the end of the project tag </Project>
you will see a bunch of <Import ...>
statements. Put the property group described in the question after these import statements:
<PropertyGroup>
<CodeAnalysisLogFile>$(IntermediateOutputPath)$(TargetFileName).CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisSucceededFile>$(IntermediateOutputPath)$(TargetFileName).lastcodeanalysissucceeded</CodeAnalysisSucceededFile>
</PropertyGroup>
For example, it should look something like this:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
...
A lot of other stuff not shown
...
-->
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<!-- The following will move the code analysis output files and put them in the intermediate folder -->
<PropertyGroup>
<CodeAnalysisLogFile>$(IntermediateOutputPath)$(TargetFileName).CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisSucceededFile>$(IntermediateOutputPath)$(TargetFileName).lastcodeanalysissucceeded</CodeAnalysisSucceededFile>
</PropertyGroup>
</Project>
(Note: Keep the contents of both <CodeAnalysisSucceededFile>
and <CodeAnalysisLogFile>
tags on a single line as shown above. Visual Studio 2019 throws an "Illegal Characters in Path" error, if you put the content across several lines.)