change solution file to a different folder

本小妞迷上赌 提交于 2020-07-31 16:00:28

问题


How do I change the folder of my existing solution file (sln)?

It's right now inside one of my project's folder; if I cut the solution file and paste it in the root folder,it doesn't load any of my projects.


回答1:


The solution file is just a text file. You should be able to move it and then edit it to make sure that any relative paths referenced in the file are correct.

I've also been able to right-click on the solution file in the solution explorer and then use save-as to save it in a different location. That doesn't seem to work everytime for me though.




回答2:


Open solution explorer in Visual Studio and select the solution.
Click on File > Save MyProject.sln As ...
and choose the new location.




回答3:


Open a blank solution, save it to a location where you would like to move. Then add "Existing Project" and select the Old.sln file to add all the projects under the old solution file.




回答4:


I just had to do this with some legacy projects I inherited so thought it might be worth documenting...

After upgrading from VS 2005 solution, I noticed that the solution file was at the same level as the project files. Our standard is to have the solution file one level above.

Undesired location of solution file.

Opening the solution file in 'Notepad' I see the following:

Unchanged Solution file opened in notpad.

Add required relative path to each of the project path and save in correct location:

In my case to bring up one level 'BloombergPriceRequestService\'

SO project line(s) will look like this:

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BloombergPaydownService", "BloombergPaydownService\BloombergPaydownService.csproj", "{17DDDD3E-CD39-48B4-BE3F-71E550FCBBFC}"
EndProject
Global

Don't forget to delete your old solution file! I have moved the solution file up one level




回答5:


if I cut the sln file and paste it in the root folder,it doesn't load any of my projects

Do this anyway, and try to open the solution. It will tell you that some projects couldn't be loaded: ignore the warning.

Then, go ahead and delete all the projects from the solution. After this right click the solution and select Add => Existing project and browse to your project file. Repeat for all projects in your solution.




回答6:


Sometimes, the solution file may contain more than 5 projects attached to it.

In that case, Creating the new solution and adding projects to that is cumbersome and takes more time.

You can just edit the solution file to load the projects correctly.

Steps to do

sdas 1. Open the solution file in notepad or any text editor. 2. update the path which is underlined and made bold.

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BloombergPaydownService", "BloombergPaydownService\BloombergPaydownService.csproj", "{17DDDD3E-CD39-48B4-BE3F-71E550FCBBFC}"

  1. Save the file and open in Visual studio.



回答7:


Editing the solution file is a hazardous way to do things and I found a better way. Just create a new solution and add copies of the folders containing the various projects (in their respective folders) to the project.




回答8:


There are two ways you can do it:

  1. Simply delete the entire project and create the entire project again in the other folder ( which is not recommended).
  2. Here are the steps to follow without missing any files.

    a. Goto Source control explorer Create a new folder or Just move the solution to which you want to move the folder to.

    b. Load the solution in your local and it will prompt a message saying that do you want to reload it from source control click yes.

    c. Once we load the solution you will see that the project you have moved won’t be loaded (Since we moved to the other folder)

    d. So now, Remove the project which was not loaded and then add it as an existing project

    e. I am sure that if you have added nugetPackages they won’t get loaded.

    f. Goto file explorer of the particular project open the .csproj file and try to check the packages location, Error condition, Project reference and Import and apart from them if there are any Which are pointing to a directory.

    g. The simplest way is just adding some nuget package and see what is the path generated by visual studio.

    h. Once we change the locations they will be loaded in references

    i. After adding references try to build the solution and it will throw some build errors because we moved the project from one folder to other.

    j. Add the project reference wherever needed after moving the files

    k. Now the build will be succeeded.




回答9:


You need

  1. to select solution in solution explorer
  2. then to find button File -> SaveAs solution.sln as
  3. Press it



来源:https://stackoverflow.com/questions/3377917/change-solution-file-to-a-different-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!