必须NuGet配置项目的包含路径吗?

时间:2017-07-03 15:42:18

标签: visual-studio nuget nuget-package casablanca cpprest-sdk

我已下载Dropbox CPP REST sample from official MS site。为了使用cpprestsdk我请NuGet下载包。它已经下载了各种工具集的包:

enter image description here

当我构建项目时出现错误:

Severity    Code    Description Project File    Line    Suppression State
Error   C1083   Cannot open include file: 'uri.h': No such file or directory    DropboxApp  d:\code_podurirest0813\dropboxapp\dropboxapp\oAuth.h    30  

uri.h是图书馆的一部分。我期待NuGet在项目中设置包含路径。我是否期望太多或者可能存在其他问题?

UPD

MS Dropbox示例对将uri.h更改为cpprest \ uri.h感到高兴。它找不到新的包含它。

由于这个原因,我创建了自己的控制台应用程序,并要求NuGet下载cpprestsdk。程序完成后,我发现没有执行自动库和包含路径设置:

enter image description here

1>  Creating directory "D:\Code_PoduriREST0813\2012\ConsoleApplication1\Debug\".
1>InitializeBuildStatus:
1>  Creating "Debug\ConsoleApplication1.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>ClCompile:
1>  stdafx.cpp
1>  ConsoleApplication1.cpp
1>d:\code_podurirest0813\2012\consoleapplication1\consoleapplication1\consoleapplication1.cpp(5): fatal error C1083: Cannot open include file: 'cpprest\uri.h': No such file or directory

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

  

我期待NuGet在项目中设置包含路径。我是否期望太多或者可能存在其他问题?

不,在安装该软件包后,NuGet会自动设置头文件和库路径,无需手动添加它们。但我们应该仔细考虑如何包含头文件。您会注意到“cpprest”文件夹中有两个子文件夹“include”,“pplx”。所以我们应该使用“cpprest\uri.h”来包含头文件:

enter image description here

因此,请检查在项目中包含头文件的方式。

<强>更新

我注意到不同之处在于Visual Studio的版本是2012(NuGet的默认版本是2.8.6),我的Visual Studio是2015(NuGet的版本是3.4.4)。然后我在Visual Studio 2012和2013上测试它,只在Visual Studio 2012上失败,不知道为什么旧版本的NuGet(2.8.6)无法自动设置库和标题路径。但是,我们无法在Visual Studio 2012中使用新版本的NuGet,因此要解决此问题,我们必须手动添加库和头文件的路径,或者您可以将Visual Studio更新到2013及更高版本。 /强>