Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio - how to BULK add files under a given directory as LINK?

How can one add in Visual Studio all the files under a given directory 'as link' (that is, without Visual Studio creating a local copy under current project's directory, which is what happens if one adds a folder as 'existing item')?

In my case, I don't want local copies. Instead, I want to work with existing items in their original locations. And, I don't want to add them by going through each folder. Instead, I want to specify a given folder and click a magic silver bullet button that adds all of the files below it as 'link'.

Thanks in advance.

(Disclaimer - I went through related questions, but all of them result in VS creating local copies.)

like image 487
Ariel Avatar asked Jan 23 '23 04:01

Ariel


2 Answers

For single files

on the add item dialog you can see a small arrow pointing down on the add button

click that (since it is a button with a dropdown) and chose the add as a link menuitem. that will add the item as link

For multiple files

on the add existing items dialog SELECT all the files you want to add as an link and press the menu item ont he add button add as a link

For Multiple files in multiple locations

If you want to select a folder and add all the items on all subfolders then you can do that this way,

on the open dialog do a search for file types you want to add, select them all and do the "add item as link" action.

Since your question changed twice including the change on the title (once) Visual Studio - how to BULK add files under a given directory as LINK? edited title I have added all the things i think you needs let me know if you still like to do something else

Hope this helps

Dan

like image 128
dmportella Avatar answered Jan 25 '23 16:01

dmportella


If you want files under an external directory to be synced automatically in your Visual Studio project (i.e any new files are added to the solution explorer and any deleted ones are removed) then you can specify a wild card in the link. Do to this you will need to edit the project file (.csproj, .vbproj) manually though.

Find the section in the file where the ItemGroup elements are located and add something like this:

  <ItemGroup>
    <Content Include="..\MyDirectory\*.*" />
  </ItemGroup>

This will add all files under MyDirectory (one level up from the project) to the solution automatically.

like image 25
Adam Avatar answered Jan 25 '23 16:01

Adam