Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeScript VsTsc error in Visual Studio 2017

I'm testing migration from VS 2015 to VS 2017 for a .NET Core / TypeScript project.

The build fails in VS 2017 with this error in Microsoft.TypeScript.targets:

MSB4064 The "PreferredUILang" parameter is not supported by the "VsTsc" task. Verify the parameter exists on the task, and it is a settable public instance property.

The version of TypeScript in VS 2017 is 2.1.5, however, I have already installed the 2.2.1 SDK for Visual Studio 2015.

I've also noted that there is no 2.2+ SDK release for Visual Studio 2017 yet.

Could this be causing conflicts? Is this something I can resolve now or do I need to wait for an update to the TypeScript SDK for VS 2017 to reach 2.2.1+?

Any help in this area appreciated!

like image 527
Sam Avatar asked Feb 05 '23 22:02

Sam


2 Answers

This might be a bit of crude solution to the problem but we simply went through the "Microsoft.TypeScript.targets" file and removed PreferredUILang="$(PreferredUILang)" from any <VsTsc ... > nodes, we had a look into the Typescript task dll and it seems that it does not have a PreferredUILang property.

It is possible that the task once upon a time did have such a property but was removed and Microsoft have forgotten to update the targets file, I'm not sure but this seems to be working for us at least.

Please make sure you backup your "Microsoft.TypeScript.targets" file before editing.

like image 133
ginja Avatar answered Feb 07 '23 11:02

ginja


I have same problem here in VS2015 Update 3 and I also fixed the Microsoft.TypeScript.targets, as suggested by ginja, but as I don't like to hack the nuget packages I went deeper in the issue.

The real problem is that when you add/upgrade the typescript nuget package, you have to manually remove the imports to the machine-wide targets and props. having both leads to unknown load order or targets/tasks, which would manifest in such errors.

So the approach I used is:

  1. Uninstall from the project the nuget packages "Microsoft.TypeScript.Compiler" and Microsoft.Typescript.MSBuild"
  2. Close VS (to guarantee the real clean of such package)
  3. Edit you .csproj file commenting out the imports to the machine-wide targets and props: (all <Import Project="$(MSBuildExtensionsPath32)\Microsoft\...
  4. Restart VS, open the project and add again the nuget packages for Typescript. This point correctly updates your .csproj with the correct imports and configuration of the TypeScript compiler.
  5. Just for a clean safe: restart VS.
like image 40
Gianpiero Avatar answered Feb 07 '23 13:02

Gianpiero