How do we include a file in a project using code?
I want to include this file:
I also want the equivalent of this:
In code ... Is it possible?
How do we include a file in a project using code?
I want to include this file:
I also want the equivalent of this:
In code ... Is it possible?
You can do this a few ways.
Command Line:
Project File:
The project file is XML. You can open and modify it like any file.
Code:
Use
Microsoft.Build.Evaluation.Project
to inspect and modify project files. The.AddItem()
method is what you're looking for.