简体   繁体   中英

How do you create a Visual Studio Solution File (.sln) in the same directory as the web project?

I'm using VisualSVN client and server and one of the requirements for web projects to work as expected is to have the .sln in the same directory (root) as the other files.

I thought it was as simple as removing all the extra parent paths ../ and other relative paths and saving it. However when I try to open it just locks up Visual Studio.

Is there a standard way to create this type of solution file or a solution file tool to help make sure it is valid? Or am I just missing something very obvious?

/
/MyWebsite.org.sln
/Images
/App_Data
/default.aspx
/default.aspx.cs

So apparently the trick, at least the one I was seeking is that you must use ..\\MyWebsite.org or whatever the folder that contains the website files.

[EDIT] What I learned and my final .sln file for this particular project:

Here is the final Solution file that allowed me to open the website and have the .sln in the root of the web folder.

Project("{E24C65DC-7377-472B-9ABA-BCSG3B73C61A}") = "MyWebsite.org", "\", "{F8F4E96F-40BF-4374-B8BA-968D0SGG4A9E}"
    ProjectSection(WebsiteProperties) = preProject
        TargetFramework = "3.5"
        Debug.AspNetCompiler.VirtualPath = "/MyWebsite.org"
        Debug.AspNetCompiler.PhysicalPath = "..\MyWebsite.org\"
        Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\MyWebsite.org\"
        Debug.AspNetCompiler.Updateable = "true"
        Debug.AspNetCompiler.ForceOverwrite = "true"
        Debug.AspNetCompiler.FixedNames = "false"
        Debug.AspNetCompiler.Debug = "True"
        Release.AspNetCompiler.VirtualPath = "/MyWebsite.org"
        Release.AspNetCompiler.PhysicalPath = "..\MyWebsite.org\"
        Release.AspNetCompiler.TargetPath = "PrecompiledWeb\MyWebsite.org\"
        Release.AspNetCompiler.Updateable = "true"
        Release.AspNetCompiler.ForceOverwrite = "true"
        Release.AspNetCompiler.FixedNames = "false"
        Release.AspNetCompiler.Debug = "False"
        VWDPort = "1603"
        VWDDynamicPort = "false"
        VWDVirtualPath = "/"
    EndProjectSection
EndProject

Generally what I do is start with a Blank Solution, which is under "Other Project Types-->Visual Studio Solutions" in the New Project dialog. Then, add the website and whatever other projects you need to the solution.

另一个选择是在创建项目时只需取消选中“create directory for solution”的默认框

the following steps should work.

  1. make a blank solution, nothing in it.
  2. Move the solution to where you want the web project to live.
  3. Open the solution.
  4. Create the web project in the desired area.

I often do this sort of moving around so that projects will sit nicely in svn. Don't forget to svn:ignore the *.suo files.

转到工具 - >选项 - >项目和解决方案,然后选中始终显示解决方案。

创建解决方案,关闭它,将文件放在您想要的位置,然后编辑sln。

I couldn't find a solution file for my project. I was able to run the project on one machine without a .sln in the project. The reason it worked on the machine I created it on was that that I keep my VS projects under C:\\Dev\\Projects but Visual Studio kept its .sln file c:\\users\\xyz\\documents\\VisualStudio2015\\projects directory. When I moved the files to a new computer the .sln wasn't in the same directory. I just found the project set up in the old computer in the c:\\users\\xyz\\documents\\VisualStudio2015\\projects directory and moved that to my new computer. I believe I could have avoided this by changing the Tools->Options->Projects and Solutions section

Re-create a project from existing files in asp.net

Copy the existing files to a location eg. F:\\Copy_webSite

Open visual studio > file > new website.

[enter image description here][1] Select the folder where you copied the files [enter image description here][2]

You will be prompted “web site already existed” select “open the existing web site”

System will create the .sln file in folder C:\\Users\\user\\Documents\\Visual Studio 2005\\Projects\\WebSite [enter image description here][3]

System will open the current project. You can also copy the the .sln file in the same folder of the current project. It will open the project in the folder

Just had to do this after a bad OS install resulted in partition damage and had to recover the data. Months later I needed to change code but the .sln file was gone.

Using Visual Studio 2015 Go to New -> Website -> Select the root directory of the website in need of a new .sln file -> Next -> It will ask to create new site in directory or open the website in directory, obviously select the latter. Opened no problem with zero errors and it was even fast at doing it -> Save project and you're good to go.

Occam's Razor!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM