Thursday, November 7, 2013

Renaming Project Solution and Items

You may also like to see:
Visual Studio : Difference in Clean, Build and Rebuild solutions

Today I need to rename one of my Project Solution.It is actually complex to do correctly because the project name is used in several places.

Here are the steps you need to follow to rename a solution:

Step 1:

In Solution Explorer, right-click the project, select Rename, and enter a new name.

Step 2:

In Solution Explorer, right-click the project and select Properties. On the Application tab, change the "Assembly name" and "Default namespace".

Step 3:

In the main CS file (or any other code files), 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 WindowsFormsApplication1



Step 4:

Change the AssemblyTitle and AssemblyProduct in Properties/AssemblyInfo.cs.

[assembly: AssemblyTitle("New Name Here")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("New Name Here")]
[assembly: AssemblyCopyright("Copyright ©  2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Step 5:

Delete bin and obj directories physically.

Step 6:

Rename the project physical folder directory.

Step 7:

Open the SLN file (within notepad or any editor) and change the path to the project.

Step 8:

Cleans and Rebuild the project

Here it is now your project is completely renamed.

If you found any other step I missed. Please comment here.

You may also like to see:
Visual Studio : Difference in Clean, Build and Rebuild solutions

16 comments:

  1. Thanks for the tips. They helped :-)

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Sorry. maybe I'm just stupid but what is the main CS file?

    ReplyDelete
    Replies
    1. Open any .CS file and rename namespace as describe in steps.

      Delete
  4. What if the project is under TFS? Would the mentioned steps change the TFS side information too? Thanks.

    ReplyDelete
  5. for vb.net should i skip step 3 and 4

    ReplyDelete
  6. how about the edmx files??

    ReplyDelete
  7. Thank you very much sir :)

    ReplyDelete
  8. Might be too obvious to mention, but also change the name of the .sln file.

    ReplyDelete
  9. Step 2: Add the point that should change the main method reference as well.

    Perfect post though. Thank you.

    ReplyDelete

Life insurance policy, bank loans, software, microsoft, facebook,mortgage,policy,