Naresh
Naresh

Reputation: 2673

Code to add a C# class file to a project

Can anybody provide some code block to add an existing C# file to a project.

I have 2 projects in my solution. One project generates C# class files which will be use by second project. I have to incluse these generated files in the second project and build the project. It should be done through programatically. I know that to include these files I have to edit the C#project file (which is an XML) and make an entry that file. But I thought of using existing code if anybody has it.

Thanks

Upvotes: 2

Views: 2220

Answers (1)

Felice Pollano
Felice Pollano

Reputation: 33252

You can ahve a look at the MsBuild.Engine namespace. It allows you to manipulate a csproj in a consistent way so you can oper the target project and add the reference programmatically.

Upvotes: 1

Related Questions