Reputation: 565
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.
Upvotes: 7
Views: 1396
Reputation: 1
Add below line in your project csproj file.
<ItemGroup>
<Content Include="<file path respective of your project>" />
<ItemGroup>
Example:
<ItemGroup>
<Content Include="Common\Constants.cs" />
<ItemGroup>
Upvotes: 0
Reputation: 565
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>
Upvotes: 4
Reputation: 479
I'm guessing you could make a new project, in the Configuration Manager select that project not to build.
The issue is you would have to reference the project. You could solve this by replacing the result with something already done, like a file with 'Copy to output folder' set.
Upvotes: 0