Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Updating Typescript in VS2015/ASP.NET MVC

0.00/5 (No votes)
5 Sep 2017 1  
A how-to and fixing common errors

Background

The newer versions of Typescript have some rather useful additions like keyof. Unfortunately, VS2015 supports 1.8 by default. After having issues with the upgrade and the internet suggesting to install multiple nuget packages until it magically fixes itself, I decided to figure out what was actually going wrong. This is a guide to hopefully help others avoid having to do that.

The Problem

After installing the nuget packages Microsoft.Typescript.MSBuild and Microsoft.Typescript.Compiler for the version of Typescript you want to use, random errors prevent building such as:

  • tsc.exe has exited with code 1.
  • IsFileSystemCaseSensitive is not supported by the FindConfigFiles task.
  • Various other errors related to tasks.

The errors were pretty inconsistent for me and seemed to change whenever Visual Studio was restarted.

The Solution

The issue is that the nuget packages don't remove the built-in support for Typescript. This causes inconsistencies in what version of the Typescript imports you're using. Luckily, the fix is pretty simple.

First, unload your project by right-clicking and selecting "Unload Project".

Now, right-click your project again and select "Edit xxxxx.csproj".

You want to comment out or delete the Typescript imports that start with $(MSBuildExtensionsPath32) as those are the built-in imports for Typescript. One is located near the top of the csproj file and the other near the bottom. If you installed the nuget packages, you should see the new Typescript imports as well. Let those be.

There is also a <TypeScriptToolsVersion> element where you can change the version but I don't think this is used by anything other than the built-in Typescript compiler. I changed it to show the accurate version in case it's used in the future. Also ensure the props import is before the targets import else you'll get more errors.

That's it! Enjoy the new versions of Typescript!

History

  • 9/1/2017: Initial release
  • 9/5/2017: Update to the revision. Formatting.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here