.NET应用重命名时遇找不到项目信息问题求助
问题场景
原.NET应用名称为HeyReady,重命名为SkillConnect后已修改内部类库名称及对应引用,应用可正常运行。但修改文件夹名称后出现找不到项目信息的报错,已更新Program.cs所在项目的ProjectReference配置,问题仍未解决。
报错信息
Unable to find project information for 'D:\PROJECTS\SKILL CONNECT\SKILL-CONNECT-BACKEND\SkillConnect.Services\SkillConnect.Services.csproj'. If you are using Visual Studio, this may be because the project is unloaded or not part of the current solution so run a restore from the command-line. Otherwise, the project file may be invalid or missing targets required for restore.
Unable to find project information for 'D:\PROJECTS\SKILL CONNECT\SKILL-CONNECT-BACKEND\SkillConnect.ApplicationContext\SkillConnect.ApplicationContext.csproj'. If you are using Visual Studio, this may be because the project is unloaded or not part of the current solution so run a restore from the command-line. Otherwise, the project file may be invalid or missing targets required for restore.
Unable to find project information for 'D:\PROJECTS\SKILL CONNECT\SKILL-CONNECT-BACKEND\SkillConnect.MiddleWare\SkillConnect.MiddleWare.csproj'. If you are using Visual Studio, this may be because the project is unloaded or not part of the current solution so run a restore from the command-line. Otherwise, the project file may be invalid or missing targets required for restore.
已更新的ProjectReference配置
<ItemGroup> <ProjectReference Include="..\SkillConnect.ApplicationContext\SkillConnect.ApplicationContext.csproj" /> <ProjectReference Include="..\SkillConnect.MiddleWare\SkillConnect.MiddleWare.csproj" /> <ProjectReference Include="..\SkillConnect.Services\SkillConnect.Services.csproj" /> </ItemGroup>
项目目录截图

解决步骤
1. 检查并更新解决方案文件(.sln)中的项目路径
解决方案文件会记录每个项目的物理路径,修改文件夹名称后旧路径不会自动更新:
- 找到后缀为
.sln的解决方案文件,用文本编辑器打开 - 查找所有包含旧文件夹名称的行(如原
HeyReady.*路径),替换为新的SkillConnect.*路径 - 保存后重新打开解决方案
2. 清理并重新还原项目
- 命令行方式:在解决方案根目录执行以下命令
dotnet clean dotnet restore dotnet build - Visual Studio方式:右键解决方案,依次选择「清理解决方案」→「还原NuGet包」→「生成解决方案」
3. 检查所有类库项目的跨引用路径
除主项目外,类库之间的引用也可能残留旧路径:
- 打开每个类库的
.csproj文件,检查其中的ProjectReference节点 - 确保所有引用路径都指向新文件夹,无拼写错误
4. 重新加载项目到解决方案
若上述步骤无效,尝试重新添加项目:
- 在Visual Studio中右键解决方案→「移除」报错的项目
- 右键解决方案→「添加」→「现有项目」,选择新文件夹下对应的
.csproj文件重新添加
5. 验证路径的大小写与特殊字符
Windows系统虽不区分大小写,但.NET工具对路径大小写敏感,确保文件夹名、项目文件名与配置中的路径完全一致,避免空格或特殊字符导致解析问题
内容的提问来源于stack exchange,提问作者DIBYA RANJAN ROUT

