CMake 的 VS_PACKAGE_REFERENCES 未添加对 VS2017 项目的引用

我正在尝试使用 CMake 自动向我的 (C++) Visual Studio 2017 项目添加 (nuget) 引用.

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

在 this 问题中,建议使用 VS_PACKAGE_REFERENCES,可从CMAKE 3.15.所以,我在我的 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>

但是,解决方案资源管理器中不显示引用,也没有将任何包含文件夹添加到项目中.似乎没有考虑 PackageReference 元素.

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.

有人知道如何解决这个问题吗?我正在使用 CMake 3.15.3,它不会给出任何错误或警告.

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

推荐答案

嗯,根据 docs.microsoft.com

面向完整 .NET Framework 的 ASP.NET 应用程序仅包括有限的支持 PackageReference.C++ 和 JavaScript 项目类型是不受支持.

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

这使得 CMake 中的整个 VS_PACKAGE_REFERENCES 选项不适用于 C++ 项目.

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

相关文章