简体   繁体   English

在Visual Studio中将解决方案.sln文件存储在哪里?

[英]Where to store solutions .sln file in Visual Studio?

I read few things regarding this issue but I'm still a bit confused so I will try to present my scenario and questions. 我读了一些关于此问题的内容,但我仍然有些困惑,因此我将尝试介绍我的情况和问题。

First of all I read that you shouldn't store your .sln file in the same folder as .csproj. 首先,我读到您不应该将.sln文件存储在与.csproj相同的文件夹中。 The reason for this is that when you will try to add a new project it will be added above the directory with .sln file. 这样做的原因是,当您尝试添加新项目时,它将以.sln文件添加到目录上方。

This is from Visual studio 2010 best practices: [Link] 这是从Visual Studio 2010最佳实践中摘录的: [链接]

Now I'm using VS 2013 so is this any different ? 现在我正在使用VS 2013,这有什么不同吗? Because when I create a new project its root folder is placed exactly where the .sln file is.This is for all the projects created using New project... in Visual studio and later using Add new project.. clicking on solution in Visual Studio. 因为当我创建一个新项目时,它的根文件夹恰好位于.sln文件的位置。这是针对在Visual Studio中使用“新建项目...”创建的所有项目,之后是在“添加新项目”中创建的所有项目。.单击Visual Studio中的解决方案。

The reason I ask this is because I copied a project using this step by step [Link] 我之所以这样问,是因为我使用此步骤逐步复制了一个项目[链接]

and everything is working great except the part with the .sln placing. 除.sln放置的部分外,其他所有东西都运行良好。 To copy the project I delete the .sln of the first project and let visual studio create a new one. 要复制项目,我删除第一个项目的.sln,然后让Visual Studio创建一个新项目。 By default Visual studio tries to do that in the same directory as .csproj. 默认情况下,Visual Studio尝试在与.csproj相同的目录中执行此操作。 So I go one directory above and place the .sln there. 因此,我在上面的一个目录中放置了.sln。 The problem is with adding a new project. 问题在于添加新项目。 It actually starts to behave as in the example from Visual Studio best practices book (creates new project one directory above). 实际上,它的行为开始像Visual Studio最佳做法手册中的示例一样(在上面的一个目录中创建新项目)。

I hope all of this is not too confusing. 我希望所有这些都不要太混乱。 If so I can elaborate. 如果是这样,我可以详细说明。

This is a very important topic since I will be doing this fairly often(copying projects) and I need this to work exactly as it should. 这是一个非常重要的主题,因为我将经常执行此操作(复制项目),因此我需要使其完全正常工作。

Cheers! 干杯!

If you create a new project from scratch, you'll see how Visual Studio creates a project / solution by default: 如果您从头开始创建新项目,则将看到Visual Studio默认情况下如何创建项目/解决方案:

  • Solution Folder 解决方案文件夹
    • Solution.sln Solution.sln
    • Project1 Folder Project1文件夹
      • Project1.csproj Project1.csproj
    • Project2 Folder Project2文件夹
      • Project2.csproj Project2.csproj
    • etc 等等

When you create a new project (File-->New-->Project) there is a check box Create directory for solution . 当您创建一个新项目(文件->新建->项目)时,会有一个复选框Create directory for solution Ensure that is checked to create a folder for your solution and a sub-folder for your project. 确保选中该复选框以为您的解决方案创建一个文件夹,并为您的项目创建一个子文件夹。

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

相关问题 如何以编程方式在当前打开的Visual Studio IDE中打开.sln文件? - How to open a .sln file in the current open Visual Studio IDE programmatically? 怎么开 <visualStudioProject> Visual Studio 2012中的.sln TXT文件 - How to open <visualStudioProject>.sln TXT file in visual studio 2012 从Win Form应用程序运行SLN文件(Visual Studio解决方案) - Run SLN file (visual studio solution) from win form application 如何在 Visual Studio 2019 中更新 .sln(解决方案)文件 - How to update .sln (solution) file within Visual Studio 2019 以编程方式获取与Visual Studio解决方案文件(* .sln)中的GUID相匹配的Assembly GUID - Getting Assembly GUID programmatically that matches that in Visual studio solution file (*.sln) 使用 Visual Studio Code 创建 C# .sln 文件 - Create C# .sln file with Visual Studio Code Visual Studio 2008要求将更改保存到.SLN文件 - Visual Studio 2008 asking to save changes to .SLN file 编译失败,sln文件加载了Roslyn,但在Visual Studio中编译 - Compilation fails with sln file loaded with Roslyn, but compiles in Visual Studio 使用Visual Studio 2019构建现有的Sln失败 - Building existing sln fails with Visual Studio 2019 如何使用C#代码在较旧的Visual Studio中打开.sln文件? - How do I open an .sln file in older Visual Studio in C# code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM