2
votes

I am building my project on a Visual Studio online HOsted server which says it it is running an older version:

PreComputeCompileTypeScriptWithTSConfig:
  C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe has TypeScript 2.0.6 installed.  

When I attempt to build, I get build errors which I believe are being caused as --project "d:_work\9\s\Main\SRC\Portal\tsconfig.json" CompileTypeScriptWithTSConfig: C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe --project "d:_work\9\s\Main\SRC\Portal\tsconfig.json" ##[error]VSTSC(0,0): Error TS5023: Build: Unknown compiler option 'baseUrl'. VSTSC : error TS5023: Build: Unknown compiler option 'baseUrl'. [d:_work\9\s\Main\SRC\MyProject.csproj] ##[error]VSTSC(0,0): Error TS5023: Build: Unknown compiler option 'paths'. VSTSC : error TS5023: Build: Unknown compiler option 'paths'. [d:_work\9\s\Main\SRC\MyProject.csproj] ##[error]VSTSC(0,0): Error TS5023: Build: Unknown compiler option 'typeRoots'. VSTSC : error TS5023: Build: Unknown compiler option 'typeRoots'. [d:_work\9\s\Main\SRC\MyProject.csproj] Done Building Project "d:_work\9\s\Main\SRC\MyProject.csproj" (default targets) -- FAILED. Done Building Project "d:_work\9\s\Main\Solutions\MyProject.sln" (default targets) -- FAILED.

I have a specified

<TypeScriptToolsVersion>2.0</TypeScriptToolsVersion>

In my project file, but it doesn't seem to be recognized. What am I missing to force the newwer TS version to run? Is this being caused by something else possibly?

UPDATE: It appears I can downgrade to 1.7 and it will recognize (but break obviously), but it will not use 2.0 - which would indicate that it is not installed on the Hosted machine. After setting the build command manually to

I then get the error

[error]C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TypeScript\Microsoft.TypeScript.targets(165,5):

Error : Your project file uses a different version of the TypeScript compiler and tools than is currently installed on this machine. No compiler was found at C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.0\tsc.exe. You may be able to fix this problem by changing the element in your project file.

But according to this: https://www.visualstudio.com/en-us/docs/build/admin/agents/hosted-pool#software - it should be installed (using Visual Studio 15), correct?

1
Check PATH environment variable. It should point to 2.0 typescript folder and not 1.8. If you don't have 2.0 at path C:\Program Files (x86)\Microsoft SDKs\TypeScript\ then install Typescript for Visual studio 2015Pankaj Kapare
This is the MS VSO hosted build server, so I cannot do anything to it, but according to this: visualstudio.com/en-us/docs/build/admin/agents/… it should be installed.naspinski

1 Answers

3
votes

The test result is the same to you, it still uses 1.8.

Refer to these steps to deal with this issue:

  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.6\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>