Visual Studio Team Services build Typescript error

2019-06-16 15:46发布

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?

3条回答
可以哭但决不认输i
2楼-- · 2019-06-16 16:21

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>
    
查看更多
做个烂人
3楼-- · 2019-06-16 16:27

TypeScript 2.0.6 is now available to the hosted build agent.

https://www.visualstudio.com/en-us/docs/build/admin/agents/hosted-pool

查看更多
神经病院院长
4楼-- · 2019-06-16 16:32

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
查看更多
登录 后发表回答