skip to Main Content

I have created one new ASP.net web api project in VS 2022. While building that default project for first time i am getting this error

Severity Code Description Project File Line Suppression State
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 FilesMicrosoft Visual Studio2022ProfessionalMSBuildCurrentBinamd64" directory. WebApplication5 C:Program FilesMicrosoft Visual Studio2022ProfessionalMSBuildMicrosoftVisualStudiov17.0TypeScriptMicrosoft.TypeScript.targets 69

That error point to Microsoft.TypeScript.targets file in this file path
C:Program FilesMicrosoft Visual Studio2022ProfessionalMSBuildMicrosoftVisualStudiov17.0TypeScriptMicrosoft.TypeScript.targets


  <!-- At least one SDK must be installed for FormatLocalizedString to exist, and if no SDKs are installed, there's nothing to report -->
  <Target Name="ReportTypeScriptVersion" BeforeTargets="Build" Condition="$(LastKnownTypeScriptVersion) != ''">
    <FormatLocalizedString Condition="'$(TypeScriptVersionCheckResult)' == 'NoneSpecified'"
      Culture="$(PreferredUILang)"
      Name="TypeScriptNoVersionWarning"
      Arguments="$(LastKnownTypeScriptVersion)">
      <Output TaskParameter="String" PropertyName="TypeScriptNoVersionWarning" />
    </FormatLocalizedString>

    <FormatLocalizedString Condition="'$(TypeScriptVersionCheckResult)' == 'Downgrade' OR '$(TypeScriptVersionCheckResult)' == 'Upgrade'"
      Culture="$(PreferredUILang)"
      Name="TypeScriptVersionMismatchWarning"
      Arguments="$(TypeScriptToolsVersion);$(LastKnownTypeScriptVersion)">
      <Output TaskParameter="String" PropertyName="TypeScriptVersionMismatchWarning" />
    </FormatLocalizedString>

    <PropertyGroup>
      <!-- Don't emit any warnings about TS version if TypeScriptCompileBlocked is set or if there is nothing to compile -->
      <TypeScriptShowVersionWarning Condition="'$(TypeScriptShowVersionWarning)' == '' AND '$(TypeScriptCompileBlocked)' != 'true' AND ('@(ConfigFiles)' != '' OR '@(TypeScriptCompile)' != '')">true</TypeScriptShowVersionWarning>
    </PropertyGroup>

    <Warning Condition="'$(TypeScriptShowVersionWarning)' == 'true' AND '$(TypeScriptVersionCheckResult)' == 'NoneSpecified'" Text="$(TypeScriptNoVersionWarning)" />
    <Warning Condition="'$(TypeScriptShowVersionWarning)' == 'true' AND ('$(TypeScriptVersionCheckResult)' == 'Downgrade' OR '$(TypeScriptVersionCheckResult)' == 'Upgrade')" Text="$(TypeScriptVersionMismatchWarning)" />
    <Warning Condition="'$(TypeScriptBuildMode)' == 'true' AND ($(TypeScriptToolsVersion.StartsWith('2.')) OR $(TypeScriptToolsVersion.StartsWith('1.')))" Text="TypeScriptBuildMode requires TypeScriptToolsVersion 3.0 or higher" />
  </Target>

This my project file xml

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
  </ItemGroup>

</Project>

enter image description here

2

Answers


  1. This appears to be a known issue that was supposed to be Fixed In Visual Studio 2022 version 17.0.1.

    Long story short, the project is importing the Typescript targets and it can’t find the tasks in your computer. This happens because the installation of VS 2022 adds a second path for the SDKs to the Windows PATH variable, which causes this behavior. You can see your PATH variable using the following at the command line:

    echo %PATH%
    

    You should see the dotnet path repeated in there somewhere with a slightly different location:

    C:Program Files (x86)dotnet

    C:Program Filesdotnet

    Reinstall the SDK you need for your machine to fix this and make sure the installation path matches the above.

    Login or Signup to reply.
  2. In the project properties screen, change the type script version to the latest version, or install the missing typescript version if you need a specific one, see the below image

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search