Search code examples
c++visual-studiovisual-studio-2017nuget

CMake's VS_PACKAGE_REFERENCES not adding a reference to VS2017 project


I'm trying to automatically add (nuget) references to my (C++) visual studio 2017 project using CMake.

In this question, VS_PACKAGE_REFERENCES is suggested, available from CMAKE 3.15. So, I've added the following to my CMAKE code:

set_property(TARGET MyApplication
    PROPERTY VS_PACKAGE_REFERENCES "BaseUtils.Native.Dynamic_0.4.0.38060"
)

And the following is nicely added to my project:

  <ItemGroup>
          <PackageReference Include="BaseUtils.Native.Dynamic" Version="0.4.0.38060" />
  </ItemGroup>

However, the reference is not show in the solution explorer, nor are any include folders added to the project. It seems that the PackageReference element is in no way taken into account.

Anyone any idea how to solve this? I'm using CMake 3.15.3, which doesn't give any errors or warnings.


Solution

  • Hmm, apparantly, C++ projects are not supported by PackageReference according to learn.microsoft.com

    ASP.NET apps targeting the full .NET Framework include only limited support for PackageReference. C++ and JavaScript project types are unsupported.

    This makes the whole VS_PACKAGE_REFERENCES option from CMake inapplicable for C++ projects.