lostinthesauce
lostinthesauce

Reputation: 23

Header file for installed NuGet package not recognized in Visual Studio

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.

Upvotes: 2

Views: 4622

Answers (1)

Leo Liu
Leo Liu

Reputation: 76910

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.

Upvotes: 7

Related Questions