Proper way to rename solution (and directories) in

2019-01-03 11:07发布

I have a rather involved Visual Studio solution (2010, but it shouldn't matter) that I need to rename.

I want to rename the folders to match the new solution name, but I can't figure out a way to refactor the folder names automatically, and going through every single project file will be painful.

Is there an official way to do this? Alternatively (and much less preferably), are there free tools to accomplish this?

17条回答
地球回转人心会变
2楼-- · 2019-01-03 11:56

To rename a website:

http://www.c-sharpcorner.com/Blogs/46334/rename-website-project-in-visual-studio-2013.aspx

locate and edit IISExpress's applicationhost.config, found here: C:\Users{username}\Documents\IISExpress\config

查看更多
▲ chillily
3楼-- · 2019-01-03 11:57

Delete your bin and obj subfolders to remove a load of incorrect reference then use windows to search for old name.

Edit any code or xml files found and rebuild, should be ok now.

查看更多
干净又极端
4楼-- · 2019-01-03 11:59

Below is a step-by-step way of renaming your entire solution in Visual Studio 2013

Assuming we're changing a project named "HelloWorld.ui" to "Section1to5.ui"

  1. Go to solution explorer (screenshot below), right click on the project that you wish to rename and select "Rename". Enter the new name that you desire.

Solution Explorer Screenshot

  1. Right click on the Project that you have just renamed, and click on "Properties". Under the Application tab, change the "Assembly name" and "Default namespace".

  2. In the main Program.cs file (or any other code files that you may have created), rename the namespace declaration to use the new name. For this right-click the namespace and select Refactor > Rename enter a new name. For example:

    namespace HelloWorld.ui ----> namespace Section1to5.ui

  3. Next, expand the "Properties" and double click on AssemblyInfo.cs file. You will notice the below code fragment:

[assembly: AssemblyTitle("HelloWorld.ui")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("HelloWorld.ui")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

You need to change the AssemblyTitle and AssemblyProduct in Properties/AssemblyInfo.cs to the new name, in this example from "HelloWorld.ui" to "Section1to5.ui". Once you're done changing the name, save and close Visual Studio.

  1. In the project directory, go inside the folder "HelloWorld.ui" and delete the "bin" and "obj" directories.

  2. Once you're done, rename the folder "HelloWorld.ui" to the new project name.

  3. Open the renamed solutions file with a text editor such as Notepad or Notepad++ and edit the following line:

    Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld.ui", "HelloWorld.ui\HelloWorld.ui.csproj", "{39FC65A3-3AE7-4EC9-B8F7-74F971636C70}"

Replace all the instances of "HelloWorld.ui" the new name that you've selected for your project, in this case "Section1to5.ui". This changes the path of the project to the renamed directory in step 6.

  1. Open the solutions file with visual studio, and clean and rebuild the project.

  2. You may notice that the "Debug/Run" button has been replaced by the "Attach" button. If this happens, simply right click on the project and choose the "Set as StartUp project" option. Alternatively, click on Tools>Customize>Commands>Add command>Debug and add the button.

You're done renaming the project, if you have any doubts feel free to post and I'd be glad to help out!

查看更多
5楼-- · 2019-01-03 12:01

I'm new to VS. I just had that same problem: Needed to rename an started project after a couple weeks work. This what I did and it worked.

  1. Just in case, make a backup of your folder Project, although you won't be touching it, but just in case!
  2. Create a new project and save it using the name you wish for your 'new' project, meaning the name you want to change your 'old' project to.
  3. Build it. After that you'll have a Project with the name you wanted but that it does not anything at all but open a window (a Windows Form App in my case).
  4. With the new proyect opened, click on Project->Add Existing Ítem and using Windows Explorer locate your 'old' folder Project and select all the files under ...Visual Studio xxx\Projects\oldApp\oldApp
  5. Select all files in there (.vb, .resx) and add them to your 'new' Project (the one that should be already opened).
  6. Almost last step would be to open your Project file using the Solution
    Explorer and in the 1st tab change the default startup form to the form it should be.
  7. Rebuild everything.

Maybe more steps but less or no typing at all, just some mouse clicks. Hope it helps :)

查看更多
你好瞎i
6楼-- · 2019-01-03 12:02

along with answer of this link

https://stackoverflow.com/a/19844531/6767365

rename these files. I renamed my project to MvcMovie and it works fine enter image description here

查看更多
我欲成王,谁敢阻挡
7楼-- · 2019-01-03 12:03

You can:

  1. click file-> new ->create project from existing project

  2. select your original file, eg. solution 1 and input the new file name solution 2

  3. change the project name in the new solution 2

查看更多
登录 后发表回答