Is it possible to rename a project in Visual Studi

2020-07-10 07:37发布

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?

5条回答
叼着烟拽天下
2楼-- · 2020-07-10 07:53

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.

查看更多
▲ chillily
3楼-- · 2020-07-10 07:55

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.

查看更多
混吃等死
4楼-- · 2020-07-10 07:56

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

查看更多
聊天终结者
5楼-- · 2020-07-10 07:57

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?

查看更多
贼婆χ
6楼-- · 2020-07-10 08:02

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.

查看更多
登录 后发表回答