You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VS2022企业版加载项目失败:InvalidProjectDataException(TargetPath为空)

解决VS 2022 Enterprise中TargetPath属性为空导致项目无法加载的问题

TargetPath属性需在项目的.csproj文件中配置,而非.sln文件,具体操作如下:

  • 找到目标项目对应的.csproj文件,用文本编辑器打开
  • 在<PropertyGroup>节点下添加或修改TargetPath属性,设置为绝对路径。可直接指定固定路径,示例:
<PropertyGroup>
  <TargetPath>C:\YourProjectDir\bin\Debug\YourProject.dll</TargetPath>
</PropertyGroup>

或使用MSBuild内置变量生成动态路径(适配不同配置和环境,推荐):

<PropertyGroup>
  <TargetPath>$(MSBuildProjectDirectory)\bin\$(Configuration)\$(AssemblyName).dll</TargetPath>
</PropertyGroup>
  • 保存.csproj文件,回到VS 2022重新加载项目即可

报错信息:

Microsoft.VisualStudio.LanguageServices.ProjectSystem.InvalidProjectDataException: Property 'TargetPath' is required to be an absolute path, but the value is ''

Microsoft.VisualStudio.LanguageServices.ProjectSystem.InvalidProjectDataException: Property 'TargetPath' is required to be an absolute path, but the value is ''
   at Microsoft.VisualStudio.LanguageServices.ProjectSystem.EvaluationData.GetRequiredPropertyAbsolutePathValue(String name)
   at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.CPS.CPSProjectFactory.<CreateProjectContextAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.LanguageServices.Workspace.<>c__DisplayClass39_0.<<OnEvaluationUpdateAsync>g__ProcessInitialEvaluationDataAsync|1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.ProjectSystem.CommonProjectSystemTools.Rethrow(Exception ex)
   at Microsoft.VisualStudio.ProjectSystem.ExceptionFilter.<>c__DisplayClass2_0.<Guard>g__Action|0()
   at GuardMethodClass.GuardMethod(Func`1 , Func`2 , Func`2 )

内容的提问来源于stack exchange,提问作者PeJ

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 13:29:28