简体   繁体   中英

Copying a project in a solution and updating namespaces - Visual studio 2015

I'm trying to copy an entire project within a solution (let's call it project A) in visual studio and update the namespace of all classes contained within the copied project.

I can successfully copy the project but I'm not able to update the namespace of all the classes in one operation.

Here's what I've tried:

-Ensuring that VS is closed, navigate to the solution in the file explorer. Make a copy of the project A folder and paste it into the solution.

-Rename project A-copy to Project B.

-Navigate to the csproj file in project B

-Open the solution in VS > select Add existing project > select the csproj file for project B

-With project B displayed in the solution explorer, right click on properties for project B and open.

-At this point the assembly name and the Default namespace are the same as project A.

-I've Updated both fields with New values and also updated the assembly information name.

-After building the project and opening any of the class files. The name space on all class files is still the same as project A

Does anyone know how I can update the name space on all class files in a single action, without having to manually update the namespace in each file?

Also tried restarting VS but this did not have any effect.

Does anyone know what I might be doing wrong

Thanks

use this:

  • press Ctrl + H
  • Find : Oldnamespace
  • Replace :Newnamespace
  • Select Entire Solution
  • List item

在此处输入图片说明

This question is already addressed in older posts. I doubt there is no single method to resolve this. 1) You can use Ctrl + H to replace the old namespace with new one. 2) Press F2 to rename the namespace, hope this replaces the old one.

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