Right-click on the project name & click reload the project. Then rename the project name as highlighted below & save. It will automatically rename the .
I tried the suggestion to remove and re-add the project, but then fixing up dependencies can be a pain.
I use this approach:
Remove the project from your solution by right-clicking it in the Solution Explorer window and choosing Remove. Move the entire project folder, including subdirectories wherever you want it to go. Add the project back to your solution.
Namespace names is something completely different, just edit the source code.
Summary: rename-and-move in VS2019 with git, retaining git history, leveraging R# a bit, automatic dependent project reference updating (important for sln's with many projects, we have >200)
I have been using the following steps to rename-and-move C# projects in Visual Studio 2019. This process uses R# to adjust namespaces. The git history is retained by doing a "git mv" (avoiding add/delete history drop).
Two phases: 1) rename the project in place and 2) move the project.
(Uses tip from base2 re unloading projects.)
Rename
Note: The folder in Windows Explorer remains the old name to this point (e.g., Utils.Foo). This is fixed in the move steps.
Move
This method: 1) retains git history, 2) leverages R# to adjust namespaces atomically and 3) updates dependent projects en masse (avoids tedious manual editing of dependent sln and csproj files).
unload all the projects in the solution (so that removal of the target project does not trigger changes in dependent projects)
VS | select all solution folders under the Solution | right-click Unload Projects
move folders using git (so history is maintained)
a) open Developer Command Prompt for 2019
b) git status (to illustrate “nothing to commit, working tree clean”)
c) git mv the project e.g., git mv "C:\Code\foo\foo\Utils.Foo" "C:\Code\Foo"
d) git status to view/verify change
VS | Solution Explorer | select project | right-click | Remove (since all projects are unloaded, this will correctly NOT remove the references to it in dependent projects)
a) VS | Solution Explorer | select target parent folder | right-click | Add | Existing Project
IMPORTANT: Confirm that *.csproj files for dependent projects have been updated.
(VS | Team Explorer | Changes | double-click any dependent csproj listed | inspect-verify ProjectReference path change)
Use Notepad++ (or other text editor) to fix the paths. Often this can be done with a simple search-and-replace (e.g., ../../../../ to ../../).
This will update...
a) GlobalAssmeblyInfo.cs references
b) paths to packages
c) paths to Dependency Validation diagram files
d) paths to ruleset paths (e.g., <CodeAnalysisRuleSet>..\..\..\..\SolutionDependencyValidation\IgnoreWarnings.ruleset</CodeAnalysisRuleSet>
)
Save All, Close Solution, I prefer to delete bin and obj folders to be clean of history, Re-open Solution
a) VS | Team Explorer | Changes
i) should see Staged Changes that reveal the files that moved ii) should see dependent projects (*.csproj) that were nicely updated review the csproj diffs and notice that the paths have been beautifully updated!! (this is the magic that avoids laboriously manually updating the csproj files using a text editor)
b) in Windows Explorer, verify old location is empty
c) Clean Solution, Rebuild Solution, Run unit tests, Launch apps in sln.
I had the same problem. I solved with move the references and in less than 15 minutes, without change the references.
For me the solution was simple:
Examples:
In solution file (.sln)
Original: Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PATH1.UI", "ScannerPDF\PATH1.UI\PATH1.UI.csproj", "{A26438AD-E428-4AE4-8AB8-A5D6933E2D7B}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PATH1.DataService", "ScannerPDF\PATH1.DataService\PATH1.DataService.csproj", "{ED5A561B-3674-4613-ADE5-B13661146E2E}"
New: Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PATH1.MX.UI", "PATH1.MX.UI\PATH1.UI.csproj", "{A26438AD-E428-4AE4-8AB8-A5D6933E2D7B}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PATH1.DataService", "PATH1.DataService\PATH1.DataService.csproj", "{ED5A561B-3674-4613-ADE5-B13661146E2E}"
In project file:
Original:
New:
Original reference: ....\lib\RCWF\2018.1.220.40\TelerikCommon.dll
New reference: ..\lib\RCWF\2018.1.220.40\TelerikCommon.dll
What worked for me was to:
..\packages
to ..\..\..\packages
since I moved the project to a deeper folder.in visual studio comunity 2019, i did what Victor David Francisco Enrique says, but needed only to delete the .vs invisbile folder
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With