简体   繁体   English

如何在与Web项目相同的目录中创建Visual Studio解决方案文件(.sln)?

[英]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. 我正在使用VisualSVN客户端和服务器,并且Web项目按要求工作的要求之一是将.sln与其他文件放在同一目录(root)中。

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. 但是,当我尝试打开它时,只需锁定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. 显然这个伎俩,至少我要求的是你必须使用.. \\ MyWebsite.org或任何包含网站文件的文件夹。

[EDIT] What I learned and my final .sln file for this particular project: [编辑]我学到了什么,以及这个特定项目的最终.sln文件:

Here is the final Solution file that allowed me to open the website and have the .sln in the root of the web folder. 这是最终的解决方案文件,允许我打开网站并在.net文件夹的根目录中包含.sln。

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. 一般来说,我所做的是从“空白解决方案”开始,该解决方案位于“新建项目”对话框中的“其他项目类型 - > Visual Studio解决方案”下。 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. 将解决方案移动到您希望Web项目生效的位置。
  3. Open the solution. 打开解决方案。
  4. Create the web project in the desired area. 在所需区域中创建Web项目。

I often do this sort of moving around so that projects will sit nicely in svn. 我经常这样做,所以项目将很好地坐在svn。 Don't forget to svn:ignore the *.suo files. 不要忘记svn:忽略* .suo文件。

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

创建解决方案,关闭它,将文件放在您想要的位置,然后编辑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. 我能够在一台没有.sln的机器上运行项目。 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. 它在我创建的机器上工作的原因是我将我的VS项目保存在C:\\ Dev \\ Projects下,但Visual Studio保留了.sln文件c:\\ users \\ xyz \\ documents \\ VisualStudio2015 \\ projects目录。 When I moved the files to a new computer the .sln wasn't in the same directory. 当我将文件移动到新计算机时,.sln不在同一目录中。 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. 我刚刚在旧计算机中的c:\\ users \\ xyz \\ documents \\ VisualStudio2015 \\ projects目录中找到了项目,并将其移动到我的新计算机上。 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 从asp.net中的现有文件重新创建项目

Copy the existing files to a location eg. 将现有文件复制到某个位置,例如。 F:\\Copy_webSite F:\\ Copy_webSite

Open visual studio > file > new website. 打开visual studio>文件>新网站。

[enter image description here][1] Select the folder where you copied the files [enter image description here][2] [在此处输入图像说明] [1]选择复制文件的文件夹[在此处输入图像说明] [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] 系统将在文件夹C:\\ Users \\ user \\ Documents \\ Visual Studio 2005 \\ Projects \\ WebSite中创建.sln文件[在此处输入图像描述] [3]

System will open the current project. 系统将打开当前项目。 You can also copy the the .sln file in the same folder of the current project. 您还可以将.sln文件复制到当前项目的同一文件夹中。 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. 几个月后,我需要更改代码,但.sln文件已经消失。

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. 使用Visual Studio 2015转到新建 - >网站 - >选择需要新的.sln文件的网站的根目录 - >下一步 - >它会要求在目录中创建新站点或打开目录中的网站,显然选择后者。 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! 奥卡姆剃刀!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果ASP.NET 5项目/解决方案没有SLN文件,如何在Visual Studio 2015 Update 1中打开它? - If an ASP.NET 5 project/solution has no SLN file how do I open it in Visual Studio 2015 Update 1? Visual Studio-网站解决方案文件-在.sln文件所在的目录中创建网站文件夹的副本 - Visual Studio - Website solution files - Creating copies of website folders in the same directory as the .sln file 如何重定位 Visual Studio 项目 (.sln) 文件 - How to Relocate Visual Studio project (.sln) file 没有sln文件时使用Visual Studio 2015打开解决方案/项目 - Opening Solution / Project with Visual studio 2015 when there is no sln file 如何在 Visual Studio 2019 中更新 .sln(解决方案)文件 - How to update .sln (solution) file within Visual Studio 2019 如何将Visual Studio的现有makefile转换回解决方案文件(* .sln)? - How do I convert an existing makefile for Visual Studio back into a solution file (*.sln)? 如何配置.sln Visual Studio Project文件存储在项目文件夹中? - How to configure .sln Visual Studio Project file to be stored in the project folder? Visual Studio Solution秘密的解决方案文件(.sln)中的全局部分? - Global Section inside Solution File (.sln) of Visual Studio Solution secret? 我是否必须退出Visual Studio for Team Explorer以检测我的Solution.sln中的“删除项目”更改? - Do I have to exit Visual Studio for Team Explorer to detect “Remove project” changes in my Solution.sln? 是否可以在不更新GUID的情况下在Visual Studio解决方案(.sln)文件中编辑项目路径? - Is it OK to edit the project paths in a Visual Studio solution (.sln) file without updating the GUIDs?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM