Header file for installed NuGet package not recognized in Visual Studio

蹲街弑〆低调 提交于 2020-12-13 04:28:44

问题


I am trying to learn Halide by walking through the tutorials. I'm working in VS 15, and have added the NuGet package for Halide and added it as a reference to my project (as shown in the image). The NuGet tutorials I've watched seem to indicate that once I add the reference, VS should automatically recognize the header file of the project, but this is not happening. I've read all the stackoverflow questions related to this, and have tried uninstalling and reinstalling the package, restarting VS, and have made sure the package is in the right project directory. I'm stuck--how do I reference Halide in Visual Studio?

screenshot of VS15

I am new to StackOverflow, Halide, and Visual Studio, so I really appreciate the help.


回答1:


Header file for installed NuGet package not recognized in Visual Studio

This issue is related to the nuget package itself. That because this package is missing a .targets file to add the header file folder to the AdditionalIncludeDirectories.

When you open the \packages folder in the solution folder, and open the folder Halide.1.0.0, you will find there is no such file Halide.targets file in the build folder. If you install the another nuget package glew, you will find the glew.targets in the folder ..\build\native with following code:

  <ItemDefinitionGroup>
    <ClCompile>
      <PreprocessorDefinitions>HAS_GLEW;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)../..//build/native/include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
    </ClCompile>
    <ResourceCompile>
      <AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)../..//build/native/include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
    </ResourceCompile>
  </ItemDefinitionGroup>

That the reason why the Header file not recognized by Visual Studio.

The workaround for this issue, you can manually add the path to the AdditionalIncludeDirectories:

Properties->C/C++->General->Additional Include Directories, add the C:\Users\<UserName>\source\repos\ConsoleApplication1\packages\Halide.1.0.0\include;%(AdditionalIncludeDirectories)

Hope this helps.



来源:https://stackoverflow.com/questions/53560792/header-file-for-installed-nuget-package-not-recognized-in-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!