简体   繁体   中英

Can not configure which Typescript compiler to use in VS 2015

I am installing Microsoft.TypeScript.MsBuild 2.0.3 NuGet package. This comes with the appropriate tsc.exe in its tools subfolder. After installing the nuget package my .csproj file contains the line:

  <Import Project="..\..\lib\Microsoft.TypeScript.MSBuild.2.0.3\build\Microsoft.TypeScript.MSBuild.props" Condition="Exists('..\..\lib\Microsoft.TypeScript.MSBuild.2.0.3\build\Microsoft.TypeScript.MSBuild.props')" />

Note: the ..\\..\\lib folder is correct, that is my package folder.

It seems all correct (except the minor trap, that Microsoft.TypeScript.targets file shipped with the package contains invalid vstsc parameter (output folder). This gives build error, which proves that this msbuild task is in effect. After correcting this annoying bug (which will arise always when refreshing packages) build is successful.

However...

Using SysInternals processexplorer I see that not the installed (NuGet) tsc.exe is called, instead this one:

C:\\Program Files (x86)\\Microsoft SDKs\\TypeScript\\1.8\\tsc.exe

Wby... ?. How to configure my project (preferably with NuGet) to use the tsc.exe I want?

All I did to create above mess is...

  1. Installing visual studio 2017 while working on visual studio 2015.
  2. And I stopped the visual studio 2017 installation as I thought I would do it in another day.

So the setup application has removed my installed typescript plugin. All you have to do is install type script for Visual Studio 2015. You can download the setup from bellow link.

https://www.microsoft.com/en-us/download/details.aspx?id=48593

Based on your description, I create a demo and reproduce your issue on our side. If you want to use C:\\Program Files (x86)\\Microsoft SDKs\\TypeScript\\1.8\\tsc.exe, please refer to the following steps.

1.Right-Click -> Unload Project

2.Right-Click -> Edit

  1. replace references to

Microsoft.TypeScript.Default.props The import should look something like:

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

Microsoft.TypeScript.targets The import should look something like:

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

在此处输入图片说明

For more information, please refer to:

https://github.com/Microsoft/TypeScript/wiki/Configuring-MSBuild-projects-to-use-NuGet

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM