Visual Studio Solutions Folder as real Folders

后端 未结 14 2353
盖世英雄少女心
盖世英雄少女心 2020-11-29 00:47

I have a Visual Studio Solution. Currently, it is an empty solution (=no projects) and I have added a few solution folders.

Solution Folders only seem to be \"virtua

14条回答
  •  没有蜡笔的小新
    2020-11-29 01:19

    The chosen answer suggests it would be possible to use actual projects instead of solution folders, but does not really explain how. I guess what I'm describing here is possibly the least awkward way of achieving that... :-P

    The problem with regular project files is that they eventually will be compiled by MSBUILD. And if you want have a project which only contains non-compilable files, that will be an issue.

    But some time ago Visual Studio introduced a new project type: Shared Project (.shproj extension). This project type does not get compiled by default, but only when (and only if) it is referenced by another project.

    So one part of the trick here is to use shared projects instead of solution folders. It's obviously possible to add a shared project that is never referenced by any other project, meaning we can avoid the issue presented above.

    Then, by using clause in the .shproj file, we can make it automatically reflect any new files and/or subfolders.

    So basically do this:

    • Create a new folder in your solution.
    • Add a new .shproj file at the root of this new folder.
    • Reference the new .shproj in your solution.

    For instance, in my case, I've created a DockerDev.shproj, so I can group some docker-related scripts that we run only in our development machines:

    
    
    
      
        
      
    
    

    This .shproj file will keep track of any file, in any subfolder of this new DockerDev folder in my solution.

    As far as I could see, this solution works pretty much like what the OP requested: it will work as a non-compilable reference to a folder, and it will automatically reflect any changes made to it.

提交回复
热议问题