Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add File to Project for Intellisense but do not Compile

I'm working on a project where we have a build tool that automatically generates source files during the build process and compiles them in. However, this setup makes us unable to get intellisense or any autocompletion when working with these generated classes. I was wondering if there was a way we could include these files as an intellisense reference without actually compiling them.

The idea being that we could copy the generated source to the target folder as part of the build task, which would then be able to be used for autocompletion, without breaking our system. I know that I can include all the contents of this folder automatically, but setting Build Action to None does not give any autocomplete functionality it would appear.

We are using Visual Studio 2013.

like image 468
Phillip Huff Avatar asked Mar 09 '15 19:03

Phillip Huff


1 Answers

So with the help of my coworkers we found a very effective solution to this problem.

Basically, MSBuild uses <CompileDependsOn> to determine where to get intellisense from. <CompileDependsOn> is supplied with a semicolon-delimited list of targets which add files to <Compile>.

For our situation, for the projects which needed intellisense, we added the following lines to the project.

<PropertyGroup>
  <CompileDependsOn>
    customTarget;$(CompileDependsOn)
  </CompileDependsOn>
</PropertyGroup>

Where customTarget is the target which adds the generated files to <Compile>

like image 89
Phillip Huff Avatar answered Nov 03 '22 08:11

Phillip Huff