简体   繁体   中英

Is it possible to rename a project in Visual Studio such that its folder name is also renamed?

Let's assume we're working on a project called MyProject. I'd like to be able to change its name to MyProject2 AND have its folder name also renamed to MyProject2.

Is this possible from Visual Studio? If not, how to make this happen "outside" it?

Rename your project to your new name. It will change the .csproj file automatically which in 2010 is the name of the project. Close Visual Studio. Rename the directory.

Open your solution file to change directory now. Your solution file will point to the new project but will reference the wrong directory.

Before:

 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stackoverflow_4560662_Rename",    "Stackoverflow_4560662\Stackoverflow_4560662_Rename.csproj", "{7CCD10BF-48BA-44E2-B071-D4ED8067ACA1}"

After

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stackoverflow_4560662_Rename", "Stackoverflow_4560662_Rename\Stackoverflow_4560662_Rename.csproj", "{7CCD10BF-48BA-44E2-B071-D4ED8067ACA1}"

Notice the two parts "Stackoverflow_4560662\\Stackoverflow_4560662_Rename.csproj" becomes "Stackoverflow_4560662_Rename\\Stackoverflow_4560662_Rename.csproj"

This is the only way I've been able to rename a directory for a project. I hope someone finds a better answer.

Following may be one solution

  • Close the solution.
  • Rename the folders outside Visual Studio.
  • Open the solution, ignoring the warnings.
  • Go through all unavailable projects.
    • Set the property 'File Path' to the new location.
    • Reload the project.
    • In case you didn't rename the project, rename it (F2).

Check answer

How do I rename a Project Folder from within Visual Studio?

I'm pretty much a novice at this stuff but I had the same issue, my resolution was to just copy and paste my code into a new project and save it using the new name I needed. Probably not the best method but it's simple and it works.

Not sure if this helps anybody but all I did was rename the solution and associated folders etc. Unfortunately when you open it says it can't find your project(s). To get around this I opened the solution itself in a text editor (notepad++) and renamed where it finds the Project . . . and it works.

Andy

Assuming you're talking about a single VB.NET project in a solution.

AFAIK, You're not supposed to rename the 'My Project' folder, that's the VS default name for all VB.NET project.

Just select the project/solution in VS Solution Explorer and Click F2 to simply rename it.

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