Reputation: 4948
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?
Upvotes: 2
Views: 1150
Reputation: 65381
You can do this a few ways.
devenv /command "File.AddExistingSolutionItem fullpath\filename"
The project file is XML. You can open and modify it like any file.
Use Microsoft.Build.Evaluation.Project
to inspect and modify project files. The .AddItem()
method is what you're looking for.
Upvotes: 5