Reorganizing directory structure for Visual Studio solution

只谈情不闲聊 提交于 2020-03-05 04:24:05

问题


My Visual Studio (VS) project/solution works as intended, but VS has somehow organized the directory structure (source files) of my project in a non-logical way.

The current directory structure

Solution Folder
    Project 1 folder
        Project 1 source files
    Sub folder
        Project 2 source files
        .sln Solution file
        Project 3 folder
            Project 3 source files

I guess I have made a mistake at some point when adding the projects to the solution in VS, since it is organized like this now.

What I would ideally like is this more clean structure:

Solution Folder
    Project 1 folder
        Project 1 source files
    Project 2 folder
        Project 2 source files
    Project 3 folder
        Project 3 sources files
    .sln Solution file

When I tried this - or whenver I move/try to reorganize the files/folders outside of VS according to the above by simply moving them around, and then try to build the solution in VS afterwards, I get the following error for (pretty much) all items:

The item (name) does not exist in the project directory.
It may have been moved, renamed or deleted.

So my question is:

How do I reorganize my folders/files for my solution outside of VS, without breaking my solution?


回答1:


For people who might be having similar obstacle, I found the answer to it from this thread:

Visual Studio move project to a different folder

As described in there, you have to delete the project you wish to move from inside your Solution Explorer in Visual Studio (VS). Afterwards, you move the project folder (outside VS) to where-ever you want it. Finally, in VS Solution Explorer, you right click on your Solution --> Add --> Existing project. Make sure you dont separate any folders or files, that belong together (be very careful/aware of this).

If you were referencing the different projects e.g. through namespaces, you have to add this again simply by right clicking the project (in Solution Explorer) that you want to reference another project --> Add --> Reference.

EDIT: Visual Studio might, for whatever reason, change which project is initializing first when building/debugging etc. If you look in VS Solution Explorer, the project which is initialized first is bold. If you need to change this, right-click on your desired start-up project --> Set as StartUp Project.

All of the above is for Visual Studio 2017



来源:https://stackoverflow.com/questions/48022705/reorganizing-directory-structure-for-visual-studio-solution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!