I'm looking for a way to have my folder structure to be the same as the one in my solution.
Something similar to what I'm looking for can be seen here: https://github.com/jasontaylordev/CleanArchitecture
The question is how can I achieve the src/tests folders separation in both Solution and Windows Explorer without using any predefined template?
Try to:
create src and test folders in the main folder where your solution is stored
open your solution with visual studio
right-click on solution -> add -> new solution folder
rename in src
rename in test
right-click on folder -> add -> existing project (or new project if it doesn't exist)
and that's all.
In this way, you will be able to see src and test folders separated in both solution and explorer.
Related
Project name is testProject. I want to create a new folder named "TestProject" and move the project into it, because I want to add testProject.uTest and testProject.iTest for unit and integration tests. So everything related is located in the same folder.
The solution is in VSTS. Already one folder exists with the same name because of the project. Namespaces will all change.
How do I go about this the best way?
I got everything to work.
First I opened the solution and deleted the project in there. Then I created the new folder in the solution explorer. I then copied all the project related files into the new folder in windows explorer. I opened up the solution and added this existing project and add all files to source contrl. Next I had to re-add nuget packages and fix some references in other projects. Next I pushed the changes and then I deleted the old project files in source control explorer.
Took 10mins and everything works fine!
A few simple steps that worked for me:
Create a folder and add some text/number at the end:
Example: Infrastructure1
Create/Add the Project to your solution without the text/number at the end.
Example: Infrastructure
Rename the folder (Infrastructure1) to match your Project name(Infrastructure).
That's it, and you will get rid of the message that Project can't be named with the same name as the folder.
I converted my MVC solution to layered architecture .
For this I added folders in my solution in Solution Explorer. Everything is working good, my colleagues are able to take the latest of solution and the folders are appearing in solution explorer.
The issue is I am not able to see the folder structure in TFS(in
Source Control Explorer.)
Probably I should have create the folder structure in TFS directly.But now I have lot of changes checked in since I created the folder, so I think this option will not work.
Please Advice.
It's supposed to be it. The root cause is Visual Studio solutions Folder are not real Folders.
Solution Folders only seem to be "virtual folders", because they are
not really created in the Filesystem and files inside solution folders
are just sitting in the same folder as the .sln file.
You can create real folders in a "project" within the solution, but not in the solution itself. Details about this area, you could refer below questions:
Visual Studio Solutions Folder as real Folders
What is a solution folder in visual studio
Source Control Explorer is used to manage files in TFVC, the files in the solution folder will shown up in the source control explorer and be the same level with .sln file, however the solution folders itself will not appearing in source control explorer and keep the folder structure.
At least for C# solutions in Visual Studio 2019 you can manage individual forders in the solution.
To do this the view has to be switched to Folder View using the Switch View button in Solution Explorer.
Look here for detailed description
Can't create folder inside Shared project in Visual Studio 2017. On place context menu I see only "New Filter"
Is it in general possible - create folder in this type project ?
Update 1: - I mean create folder not in Folder view...
Maybe you just need to enable Show all files item in Solution Explorer toolbar?
Filters are logical groupings of files, that aren't reflected in the filesystem. Creating filters is the only option available when looking at the solution view. If you want to add a filesystem folder instead you have to toggle between solution and folder view of the Solution Explorer:
Once in folder view, you can create a filesystem folder:
In general "enable Show all files item in Solution Explorer toolbar" is good desigion, but if you reopen vs2017 you need everytime enable it. So best desigion - change your settings in Tools- Options.. - VC++ Project Settings - Solution Explorer Mode - to the Show all files
I am using Visual Studio 2010 Professional.
I have created a folder inside a project in my solution using the "right click -> Add -> New folder -> folder1" method, and now my solution explorer looks like this:
Is there a way for me to programmatically access files inside this folder (ex: sampleFile.xml) from code, other than get the path of the executable and go from there?
Edit: I want to know if there's a more elegant solution provided by VS/C#, I know I can construct the path using the executable path or base directory.
For example, found this here : if I add the file as a resource (Right click on project -> Properties -> Resources -> Add Resource) a "Resource" folder is generated in my solution explorer :
and I can get the content of the file easily like this :
var newFile = Properties.Resources.newFile1;
Is there something similar for other non-resource files in the solution and can I get the path of the files in a similar way?
Assuming that Test is your main project, then the file can be accessed via:
AppDomain.CurrentDomain.BaseDirectory + #"\Folder1\SampleFile.xml"
(This assumes that: (a) you want to access it from within Visual Studio, or (b) that whatever install mechanism you use places Folder1 within the start directory of the application.)
New to Visual C#. I can add existing .cs files but is there a way to add entire code directories to C#. Otherwise I would have to create folders again within visual C# and add files into it. There has to be an easier way to replicate my existing directory structure in visual C#.
Click Show All Files in Solution Explorer to see the entire filesystem within your project directory.
You can then right-click an entire folder (or select multiple folders) and click Include in Project.
You should be able to simply drag/drop folders from an explorer window into your solution by dropping them on the project or a sub-folder.