RC1140
RC1140

Reputation: 8673

Auto Include Files In A C# Project

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

Upvotes: 2

Views: 1092

Answers (3)

Ants
Ants

Reputation: 2668

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" /> 

or

<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.

Upvotes: 7

Andrew Kennan
Andrew Kennan

Reputation: 14157

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.

Upvotes: 0

mqp
mqp

Reputation: 72015

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.

Upvotes: 2

Related Questions