Need help in Visual Studio 2019: how to disable the annoying warning about installing the 'Microsoft.TypeScript.MSBuild' NuGet package for TypeScript compilation?
If you want to suppress this warning, you can utilize the NoWarn msbuild property.
Here's a solution:
Add the following code snippet in your xxx.csproj
file:
<PropertyGroup>
<NoWarn>xxx(the related waning code like cs0219)</NoWarn>
</PropertyGroup>
================================
Update 1
If the warning does not have a number, using NoWarn
won't work. In that case, you can use:
<WarningLevel>0</WarningLevel>
However, keep in mind that this will silence all warnings in your project. To address this issue while still being able to view other warnings, consider creating a new configuration named Test and modifying your xxx.csproj
accordingly.
<PropertyGroup Condition="'$(Configuration)'=='Test'">
<WarningLevel>0</WarningLevel>
</PropertyGroup>
You can then use the Test Configuration to build your project and suppress the warning, switching to Debug or Release mode when needed.
====================
Update 2
After investigating further, I found the root cause of the issue on my side:
The error occurs because the TypeScript version is not specified in MSBuild of Visual Studio. This happens when typescript files are set to build as TypeScript file, triggering MSBuild to use Type Script for building them even if it's not intended.
To resolve this:
Change the Build Action of every typescript file to Content and add custom tool to npm run typescript
.
Restart your project after these changes, and the error should disappear.