简体   繁体   English

无法配置在 VS 2015 中使用哪个 Typescript 编译器

[英]Can not configure which Typescript compiler to use in VS 2015

I am installing Microsoft.TypeScript.MsBuild 2.0.3 NuGet package.我正在安装 Microsoft.TypeScript.MsBuild 2.0.3 NuGet 包。 This comes with the appropriate tsc.exe in its tools subfolder.这在其工具子文件夹中带有相应的 tsc.exe。 After installing the nuget package my .csproj file contains the line:安装 nuget 包后,我的 .csproj 文件包含以下行:

  <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.注意:..\\..\\lib 文件夹是正确的,那是我的包文件夹。

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.看起来都是正确的(除了小陷阱,包附带的 Microsoft.TypeScript.targets 文件包含无效的 vstsc 参数(输出文件夹)。这给出了构建错误,证明这个 msbuild 任务有效。纠正这个烦人的错误后(刷新包时总是会出现)构建成功。

However...不过……

Using SysInternals processexplorer I see that not the installed (NuGet) tsc.exe is called, instead this one:使用 SysInternals processexplorer 我看到没有调用已安装的 (NuGet) tsc.exe,而是调用了这个:

C:\\Program Files (x86)\\Microsoft SDKs\\TypeScript\\1.8\\tsc.exe 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?如何配置我的项目(最好使用 NuGet)以使用我想要的 tsc.exe?

All I did to create above mess is...我所做的一切都是为了创造上面的混乱……

  1. Installing visual studio 2017 while working on visual studio 2015.在使用 Visual Studio 2015 时安装 Visual Studio 2017。
  2. And I stopped the visual studio 2017 installation as I thought I would do it in another day.我停止了 Visual Studio 2017 安装,因为我认为我会在另一天完成。

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.您所要做的就是为 Visual Studio 2015 安装类型脚本。您可以从下面的链接下载安装程序。

https://www.microsoft.com/en-us/download/details.aspx?id=48593 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.如果要使用 C:\\Program Files (x86)\\Microsoft SDKs\\TypeScript\\1.8\\tsc.exe,请参考以下步骤。

1.Right-Click -> Unload Project 1.右键->卸载项目

2.Right-Click -> Edit 2.右键->编辑

  1. replace references to替换对

Microsoft.TypeScript.Default.props The import should look something like: Microsoft.TypeScript.Default.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')" />

Microsoft.TypeScript.targets The import should look something like: Microsoft.TypeScript.targets 导入应该类似于:

<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 https://github.com/Microsoft/TypeScript/wiki/Configuring-MSBuild-projects-to-use-NuGet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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