❔ Renaming project / solution issues (c# dev kit)
I renamed every file and every reference and when I tried debugging it couldn't find the project. Somehow it's still looking for the old name but I've done a text search for the old name in the whole directory and I see nothing. What's the safe way of doing this?
13 Replies
Use the cli tools is the safest way.
dotnet remove reference command - .NET CLI
The dotnet remove reference command provides a convenient option to remove project to project references.
dotnet sln command - .NET CLI
The dotnet-sln command provides a convenient option to add, remove, and list projects in a solution file.
Use the cli to remove things; do renames; then add everything back in/together
@Mayor McCheese I'll give it a shot. Thanks
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.Unsuccessful
The default debugging config setup by dev kit doesn't work after the rename
then whe nI try to create anothjer it says there's no c# proj in the dir,
app ran fine in vs though
It's probably more effort then it's worth; create new project structure in a new location and copy files then.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.I also experienced some very weird behaviour when I tried to rename a project/namespaces.
I changed the name in solution-explorer: that ADDED a complete structure folder in the vs code explorer but all folders empty. The corresponding files where created under the previous named folder (additionally!).
I had to manually rearrange all and then rebuild and it worked. But I think their should be a clean automated solution for renaming... I'm new to C# and found that experience almost scary
Renaming projects and solutions in c# is a skill all on its own. Believe it or not the process has gotten easier, and various opinions abound. I always work from the file system up. For example, I highly discourage renaming projects in visual studio because it's a half assed job by visual studio. If your project was named DiscoDiscordBot and changed to DiscourseDiscordBot, the file system remains DiscoDiscordBot. VS takes the safest approach, which is rational, if you have all sorts of bash and powershell scripts, VS won't know about them.
I start with the file system first, disconnecting with the dotnet cli, renaming csproj files and folders and recovering, then working any script issues, then internally letting my ide handle renamespacing.
It somehow seems like a bug in dev kit to me that renaming a project in the solution explorer creates all files in bin and obj with the new name additionally to the old name, but somehow keeps the ref to the old name for build (?). But it's very well possible that I just don't understand enough at this point. I got it working finally and could remove all files referencing the old named folder manually, but it feels rather odd to have to do so.
I've not used dev kit much, I'd encourage you to open a ticket with them if you feel like it's a bug.