windows – Auto Include Files In A C# Project – Education Career Blog

This may not really sound hard to do but it is currently killing me. Currently i have a Visual Studio 2008 C# Project that i use in conjunction with a DAL generator , its nothing fancy at all besides generating files that i can use in the project to access the database.

The problem i am having is that after the generator has run and the files are created they never show up in my project (new files , old existing files are fine). To add them i have to show hidden files (In visual studio) then include all of the files manually. So is there anyway to automatically include these files into my project.

Thanks in advance


In VS2008:

1) Right click on your project node.

2) Select “Unload project”.

3) Right click on the project node.

4) Select “Edit foo.csproj”

5) In the element add a element that includes your DAL files using wildcards like:

<Compile Include="DAL_*.cs" /> 


<Compile Include="DataAccessLayer\*.cs" /> 

6) File.Save

7) Right click on the project node.

8) Select “Reload project”.

To learn more about this read up on MSBuild.


I suppose the easiest way would be to write a tool to automatically modify the .csproj file, which is just XML, so that it includes your new items.


I’d go one further than mquander and say generate the whole project file for your DAL. When it changes I think VS should prompt you to reload it.

The csproj is an msbuild file and isn’t that hard to comprehend.

Leave a Comment