0

Below is my project structure

FirstCoreApps is a .net core empty web application.. when I am trying to add new web project CoreMVC it is adding a directory to FirstCoreApps as well, as shown in the screenshot.

I am very new to Asp.net core, please let me know what is the reason and how to deal with this....

2 Answers 2

4

When you created the second project, you seem to have accidentally created it inside of a folder in the first one.

This can happen if the solution (CoreApps.sln) file is in the same directory as the first project file (FirstCoreApps.csproj). The dialogs then probably suggested a directory that you should not have used.

Since the new project model automatically includes everything in the folder of the csproj file, the files of the second project automatically become part of the first project.

When creating new projects, be sure to check the "Create directory for solution". This creates a folder structure where the .sln file is created in its own folder and ever project in its own sub-folder.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

In .net-core6 we do not find the option "create directory for the solution". The work around which I used was,

     1.Create a folder and give proper name and move the project inside the folder.
     2.Open the solution with VS-2022.
     3.In the IDE, click on solution once, then open tab File->Save As ProjectName.sln
     4.Choose the location which is outside of the folder where you are already in.
     5.Now delete the projectname.sln file from the first location.
     6.Open the project using newly created project.sln file
     7.Add the additional project of your choice and it wont create copy of it. 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.