How do I “Add Existing Item” an entire directory structure in Visual Studio?

前端 未结 18 1273
眼角桃花
眼角桃花 2020-11-28 00:18

I have a free standing set of files not affiliated with any C# project at all that reside in a complicated nested directory structure.

I want to add them in that for

相关标签:
18条回答
  • 2020-11-28 00:59

    This is what I do:

    1. Right click on solution -> Add -> Existing Website...
    2. Choose the folder where your website is. Just the root folder of the site.

    Then everything will be added on your solution from folders to files, and files inside those folders.

    0 讨论(0)
  • 2020-11-28 01:05

    Enable "Show All Files" for the specific project (you might need to hit "Refresh" to see them)**.

    The folders/files that are not part of your project appear slightly "lighter" in the project tree.

    Right click the folders/files you want to add and click "Include In Project". It will recursively add folders/files to the project.

    ** These buttons are located on the mini Solution Explorer toolbar.

    ** Make sure you are NOT in debug mode.

    0 讨论(0)
  • 2020-11-28 01:07

    In Solution Explorer:

    1. Click Show All Files (second icon from the left at the top of Solution Explorer).
    2. Locate the folder you want to add.
    3. Right-click and select "Include in Project"

    I use this to install add-ons like HTML editors and third-party file browsers.

    0 讨论(0)
  • 2020-11-28 01:07

    There is now an open-source extension in the Marketplace that seems to do what the OP was asking for:

    Folder To Solution Folder

    If it doesn't do exactly what you want, the code is available, so you can modify it to suit your scenario.

    HTH

    0 讨论(0)
  • 2020-11-28 01:09

    At last, Visual Studio 2017 allows the user to import an entire directory with a single click. Visual Studio 2017 has a new functionality "Open Folder" that allows opening the entire folder, even without the need to save it as solution. The source code can be imported using the following methods.

    1. Menu FileOpen → *Folder (Ctrl + Shift + O)
    2. devenv.exe <source folder>

    It even supports building and debugging CMake projects.

    Bring your C++ codebase to Visual Studio with “Open Folder”

    0 讨论(0)
  • 2020-11-28 01:09

    What worked for me was to drag the folder into Visual Studio, then right click the folder and select "Open Folder in File Explorer". Then select all and drag them into the folder in Visual Studio.

    0 讨论(0)
提交回复
热议问题