NuGet product used:
MSBuild
NuGet version:
4.6.0
VS version:
15.9.6
Directory.Build.props file with a PackageReference to a nuget package which is not compatible with C++ projects, e.g. <PackageReference Include="StyleCop.Analyzers" Version="1.1.1-rc.108" PrivateAssets="all" />C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(186,5): 
error : Your project does not reference ".NETFramework,Version=v4.0" framework. 
Add a reference to ".NETFramework,Version=v4.0" in the "TargetFrameworks" property of your 
project file and then re-run NuGet restore. [C:\Git\src\github.com\xxx\xxx.vcxproj]
That nuget would only install packages into projects that are compatible.
For my own reference, I suspect there is some kind of workaround whereby I wrap the PackageReference in some kind of condition to prevent it being applied to C++ projects, something like this (I havent found the right runes yet)
<Project>
  <Choose>
    <When Condition=" '$(CustomCondition)' == 'true' ">
      <ItemGroup>
        <PackageReference Include="StyleCop.Analyzers" Version="1.1.1-rc.108" PrivateAssets="all" />
      </ItemGroup>
    </When>
  </Choose>
</Project>
(Referenced from https://github.com/dotnet/project-system/issues/4175)
Directory.build.props is imported into all files.
Yes, you'll have to own conditioning it out. (perhaps on TargetFramework?)
<ItemGroup Condition="...">
    <PackageReference ... />
</ItemGroup>
Some properties, like TargetFramework are defined by the SDK after Directory.Build.props are imported. Here are some alternate ideas:
'$(MSBuildProjectExtension)' == '.csproj'PackageReference in Directory.Build.targets in order to use properties such as TargetFramework.Directory.Build.Props it finds, not all of them, so create an empty Directory.Build.props file in the same directory as any project that doesn't support PackageReference
Most helpful comment
Some properties, like
TargetFrameworkare defined by the SDK afterDirectory.Build.propsare imported. Here are some alternate ideas:'$(MSBuildProjectExtension)' == '.csproj'PackageReferenceinDirectory.Build.targetsin order to use properties such asTargetFramework.Directory.Build.Propsit finds, not all of them, so create an emptyDirectory.Build.propsfile in the same directory as any project that doesn't supportPackageReference