Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I automatically add existing items to a Visual Studio project?

I have a tool which dynamically generates .xaml and .xaml.cs files and puts them in the appropriate Visual Studio directory.

To add them to the project, I have to then:

  • right-click on that directory
  • choose "add existing item"
  • navigate to the matching directory on the hard drive
  • select the two files that were created
  • click ok

Is there a way for me to tell the project to "include all existing items under the project folder on the hard drive"?

like image 597
Edward Tanguay Avatar asked Nov 16 '09 16:11

Edward Tanguay


People also ask

How do I add an existing file to Visual Studio project?

You can add existing files to your project by right-clicking on the Project node and selecting Add > Add Files.... Alternatively, to add an entire folder, select Add > Add Existing Folder.... The file browser is shown. It lets you search your system for the required item to add.

How do I add a solution to an existing project?

Add files to a solution To add an item to a solution, on the context (right-click) menu of the solution node in Solution Explorer, select Add > New Item, or Add > Existing Item. A solution file is a structure for organizing projects in Visual Studio.

How do I add a code to an existing Visual Studio project?

On Linux, the existing file can be inserted by copying to system's clipboard then paste from VSC. Then paste to VSC as usual using Ctrl-V.


2 Answers

You can do this programatically in your .proj file depending on your needs just like this answer

You just have to make sure you use the correct tag for the files.

Compile, Content, None, etc..

<ItemGroup>
  <Content Include="Images\**\*.*" />
  <Compile Include="Subdirectory\**\*.cs" />
</ItemGroup>
like image 108
Maslow Avatar answered Sep 30 '22 20:09

Maslow


I do not have any automation for this. Still I follow following for the same requirement. This will avoid few clicking.

  • In solution Explorer highlight/Select "Show all files" button
  • Press control key (to multi select) and select files with mouse click to be included in solution.
  • Right click on any one of highlighted file, and select "Include in project"
like image 23
Saar Avatar answered Sep 30 '22 20:09

Saar