Last post Aug 01, 2012 11:09 AM by B_WILL
Apr 27, 2009 04:08 PM|M.S|LINK
I'm wondering if there is a best practice recommendation for organization files for an ASP.NET website. Particularly if the .sln and .suo files should reside with the other files of the project (for example in wwwroot)?
The reason I ask is because VS 2008 seems to put the .sln in a different directory from the other files by default, so I wonder if there is some advantage to it.
Apr 27, 2009 04:22 PM|johram|LINK
It depends on the project type you are using. If you're working with a
web site project, you place the .sln file outside the project root. By default, the .sln is placed in my documents\Visual Studio <version>\Projects, but I always tend to place it in the parent folder of the web. So if I have a web site called Store,
I have the following (source) structure:
Where Web is the folder that contains my web files.
The reason why the .sln file should not be stored *inside* the web folder when using web site project is because the web will automatically include all files in that folder.
If you have a web application project, the project file is typically placed in the same folder as the web files. If you add more projects to your solution, you can choose where to store the solution. Typically, I would apply the same pattern
in this scenario. I keep the .sln file in the parent folder.
So if I have a web site (Store) that consists of three projects, Proj1, Proj2 and Proj3 I would keep a structure similar to this:
Apr 28, 2009 09:31 AM|M.S|LINK
Thank you. I have a followup question to that. Is there a way to specify the directory that the sln should be saved in when you start a new project, or do you have to physically move it?
Apr 28, 2009 03:53 PM|johram|LINK
For web site projects, Visual Studio is "smart" (or annoying - depending on how you see it) as it "hides" the solution for you by placing it under My documents.
A cool thing (or annoying) about this is that when you use the feature open web site from Visual Studio, it will automatically discover "hey I created a solution for this folder, let's open that solution", and it will automatically locate the .sln file stored
under My documents. It took me a while before I figured this out.
Still, it's not useful at all. What you want to do is to have full control over the placement of the solution file.
So. What you need to do is to explicitly save the solution file to the folder of your choice. When you do New web site in Visual Studio, the solution will automatically be created under My documents. But what you then can do is to right-click the solution
in the solution explorer and choose "save as".
I haven't found a way to prevent Visual Studio from creating automatic solutions under My documents, but at least you can save it to a different location.
Aug 01, 2012 11:09 AM|B_WILL|LINK
I'm having the same concerns as the original poster, but you can easily specify where VS will put the solution and project files by going to Tools - Oprions. Then expand Projects and Solutions and click on General. You will notice that the default is set
to the Visual Studio <version> location. change this to the path of your choice. Then when you create a website project, the solution files will be created here, and you don't need the extra step of saving as...
Note that you don't have to have the solution file to open an existing web site. You just open VS, go to File - Open - Web Site and brows to the folder containing your web site.