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

构建REST Core解决方案时遇MSB4036错误:找不到FormatLocalizedString任务

解决MSB4036: "FormatLocalizedString"任务未找到的构建错误

错误详情

Error MSB4036 The "FormatLocalizedString" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with in the project file, or in the *.tasks files located in the "C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64" directory. REST.Core.Host C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VisualStudio\v17.0\TypeScript\Microsoft.TypeScript.targets 69

错误截图

可行解决方案

  • 修复TypeScript构建工具
    打开Visual Studio Installer,找到你的VS2022专业版实例,点击「修改」,切换到「单个组件」标签,找到「TypeScript构建工具」选项:

    1. 若未勾选,直接勾选后点击「修改」完成安装;
    2. 若已勾选,先取消勾选并应用,再重新勾选安装,强制修复损坏的组件文件。
  • 替换损坏的Microsoft.TypeScript.targets文件
    从同版本的正常VS2022环境中,复制C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VisualStudio\v17.0\TypeScript\Microsoft.TypeScript.targets文件,覆盖你机器上的对应文件。如果没有可用的正常环境,删除该文件后通过VS Installer修复TypeScript组件,让系统自动重新生成这个文件。

  • 清理构建缓存并重新生成

    1. 删除项目目录下的bin和obj文件夹;
    2. 打开VS,依次点击「工具」→「NuGet包管理器」→「管理解决方案的NuGet包」→「设置」→「清除所有NuGet缓存」;
    3. 重启VS后重新生成整个解决方案。
  • 验证MSBuild任务注册
    检查C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64目录下的.tasks文件,确认是否存在FormatLocalizedString任务的注册项。如果缺失,通过修复VS安装来恢复这些注册文件,不要手动编辑.tasks文件避免引入新问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.19 12:07:27