Click here to Skip to main content
15,881,794 members
Articles / Web Development / ASP.NET
Tip/Trick

Updating Typescript in VS2015/ASP.NET MVC

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
5 Sep 2017CPOL2 min read 9.6K  
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".

Image 1

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

Image 2

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.

Image 3

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
Software engineer dedicated to constantly learning and improving with a focus on self-documenting code and informed design decisions. Interested in most everything. Currently diving down the rabbit-hole of functional programming and category theory.

Comments and Discussions

 
-- There are no messages in this forum --