9
votes

I'm following the tutorial on TypeScript website to add TypeScript and Angular 2 to my ASP.net MVC project. The tutorial from Typescript website can be found here.

I have followed the tutorial point by point; however I keep getting the following error at the end:

"tsc.exe" exited with code 1.

The project works perfectly up to adding Angular 2.

I have tried installing Microsoft.TypeScript.MSBuild and Microsoft.TypeScript.Compiler as they were suggested here. However that didn't fix the problem.

Any ideas on how to fix this problem?

6
Is there any other information before this to indicate why it exited with code 1? Normally you'd expect some error messages or even log file of some kind. Check this out just incase: stackoverflow.com/questions/37350183/… - Dandy
I tired the suggested solution but no results. I don't get any additional error messages, just that one! - Farshad Momtaz

6 Answers

5
votes

I resolved the build issue in VisualStudio 2015 Update 3 by adding

  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')" />

to the visual studio .csproj file.

3
votes

If you reached here while using one of these tutorials:
https://angular.io/docs/ts/latest/cookbook/visual-studio-2015.html#!#prereq4 https://www.typescriptlang.org/docs/handbook/asp-net-4.html

Try this method to install TypeScript 2.0: https://www.microsoft.com/en-us/download/details.aspx?id=48593

It seems npm adds TypeScript 2.0 to the local users folders instead of the common program folder where visual studio looks by default. The install above will add it to the common program folder, which visual studio will detect without changes to the environment variable.

HTH

2
votes

I solved this problem installing

Nuget package

> Typescript 2.0.6 for Visual Studio 2015
1
votes

Which version of tsc you have installed? You can check with tsc -v in npm console in visual studio. I had the latest version of tsc installed, but visual studio was still referring to the oldest version of tsc.

Check under - C:\Program Files (x86)\Microsoft SDKs\TypeScript to see if you the old versions of tsc as well.

I had to manually delete older version of tsc folder from the path, for visual studio to be able to pick up the latest version of tsc. Or,you can add path in the environment variable to point to the latest tsc.

0
votes

So, what I did was - I deleted the folders from the path and just kept the folder of latest tsc version. After that if you run the command tsc - v from npm console in visual Studio it will show you the latest version.

After that if you still get the same error. You can then run the command "npm install" from npm console in visual Studio. Make sure you are in the directory where you have packages.json file. It will install node modules folder with all the libraries. Once that is done you should be able to compile your project.

0
votes

I also found out that I should set the TypeScriptToolsVersion inside .csproj file to the current version of Typescript installed on the PC. Visual Studio sometimes chooses the wrong version of the Typescript.