Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Team Services build Typescript error

I have a angular2 webapplication where I'm using Typescript 2.0. I have install locally in my VS the version 2.0 and changed also the tag for the typescript version in my VS project. Locally vs build works fine. In my CD pipeline on Visual Studio Team Services with a vnext build now build fails with this:

2016-11-05T16:10:22.0371090Z   C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe --project "C:\a\1\s\src\Emersy\tsconfig.json"
2016-11-05T16:10:22.7095466Z ##[error]VSTSC(0,0): Error TS5023: Build: Unknown compiler option 'strictNullChecks'.

Looks like that the build server is using the typesript version 1.8 is this possible?

like image 603
cpiock Avatar asked Nov 05 '16 17:11

cpiock


2 Answers

Typescript 2.0 is not available in Hosted Build agent. But you could use Microsoft.TypeScript.MSBuild package instead, after that you could build your project on Hosted Agent with typescript 2.0.

  1. Add/Install Microsoft.TypeScript.MSBuild package to your project
  2. Edit your project file (.csproj)

    a.) Configure MSBuild to use the NuGet package's props file.

    <Import Project="..\packages\Microsoft.TypeScript.MSBuild.2.0.6\build\Microsoft.TypeScript.MSBuild.props" Condition="Exists('..\packages\Microsoft.TypeScript.MSBuild.2.0.3\build\Microsoft.TypeScript.MSBuild.props')" />
    <!--<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')" />-->
    

    b.) Configure MSBuild to use the NuGet package's targets file.

    <Import Project="..\packages\Microsoft.TypeScript.MSBuild.2.0.6\build\Microsoft.TypeScript.MSBuild.targets" Condition="Exists('..\packages\Microsoft.TypeScript.MSBuild.2.0.6\build\Microsoft.TypeScript.MSBuild.targets')" />
    <!--<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />-->
    

    If it is .Net Core project, add this code to section of .xproj file

    <TypeScriptToolsVersion>2.0.6</TypeScriptToolsVersion>
    <TscToolPath>C:\Users\[user account]\.nuget\packages\Microsoft.TypeScript.MSBuild\2.0.6\tools\tsc</TscToolPath>
    
like image 180
starian chen-MSFT Avatar answered Sep 21 '22 19:09

starian chen-MSFT


I don't think the Hosted build agents have support for TypeScript 2.0 at the moment.

From VisualStudio.com:

TypeScript 1.4 for Visual Studio 2013
TypeScript 1.6 for Visual Studio 2013 and Visual Studio 2015
TypeScript 1.7.5 for Visual Studio 2013
TypeScript 1.7.6 for Visual Studio 2015
TypeScript 1.8.6 for Visual Studio 2013 and Visual Studio 2015
WIX Toolset 3.10
like image 26
DaveShaw Avatar answered Sep 20 '22 19:09

DaveShaw