简体   繁体   English

ASP.NET 5 项目中的 TypeScript 工具版本设置在哪里?

[英]Where is the TypeScript Tools version set in an ASP.NET 5 Project?

I'm working with a default ASP.NET 5 Web project template and trying to determine how to dictate the TypeScript tools and ultimately compiler version for my application.我正在使用默认的ASP.NET 5 Web 项目模板,并试图确定如何为我的应用程序指定 TypeScript 工具和最终的编译器版本。

I'm not yet using Gulp so this post's answer does not seem to hold water.我还没有使用Gulp所以这篇文章的答案似乎站不住脚。 The reason being, my app even without Gulp has to be told which TypeScript compiler to use.原因是,即使没有 Gulp,我的应用程序也必须被告知要使用哪个 TypeScript 编译器。 This answer as well wasn't about finding the version but rather using features not yet supported.这个答案也不是关于查找版本,而是使用尚不支持的功能。

In VSNET 2013, the TypeScript tools version and compiler targeted was set in the project's properties:在 VSNET 2013 中,TypeScript 工具版本和目标编译器在项目的属性中设置:

<TypeScriptToolsVersion>1.7</TypeScriptToolsVersion>

I believe it to be an option of the compilerOptions section of my tsconfig.json file.我相信它是我的tsconfig.json文件的compilerOptions部分的一个选项。 However I get no intellisense for version and it appears the documentation is sparse.但是我没有得到version智能感知,而且文档似乎很少。 This link states it just emits the compiler's version but doesn't allow specifying it.链接声明它只发出编译器的版本,但不允许指定它。

I currently have version 1.6 and 1.7 installed on my machine.我目前在我的机器上安装了 1.6 和 1.7 版。 If there is a need for me to dictate a specific compiler version, how do I set that in an ASP.NET 5 web template?如果我需要指定特定的编译器版本,我该如何在 ASP.NET 5 Web 模板中进行设置? Again the answer isn't immediately to use Gulp because it builds and compiles my .ts files as is now, so something is dictating the compiler being used.同样,答案不是立即使用 Gulp,因为它像现在一样构建和编译我的.ts文件,所以某些东西决定了正在使用的编译器。

It appears the TypeScript Tools (and corresponding compiler version) for ASP.NET 5 projects is set in the following files:看来 ASP.NET 5 项目的 TypeScript 工具(和相应的编译器版本)设置在以下文件中:

TS 1.7: C:\\Program Files (x86)\\MSBuild\\Microsoft\\VisualStudio\\v14.0\\TypeScript\\Microsoft.TypeScript.targets TS 1.7: C:\\Program Files (x86)\\MSBuild\\Microsoft\\VisualStudio\\v14.0\\TypeScript\\Microsoft.TypeScript.targets

<PropertyGroup>
    <TypeScriptToolsVersion Condition="'$(TypeScriptToolsVersion)'==''">1.7</TypeScriptToolsVersion>
    <TscToolPath Condition="'$(TscToolPath)' == ''">$(MSBuildProgramFiles32)\Microsoft SDKs\TypeScript</TscToolPath>
    <TscToolExe Condition="'$(TscToolExe)' == ''">tsc.exe</TscToolExe>
    <TscYieldDuringToolExecution Condition="'$(TscYieldDuringToolExecution)' == ''">true</TscYieldDuringToolExecution>
</PropertyGroup>

TS 1.8 C:\\Program Files (x86)\\MSBuild\\Microsoft\\VisualStudio\\v15.0\\TypeScript TS 1.8 C:\\Program Files (x86)\\MSBuild\\Microsoft\\VisualStudio\\v15.0\\TypeScript

<PropertyGroup>
    <TypeScriptToolsVersion Condition="'$(TypeScriptToolsVersion)'==''">1.8</TypeScriptToolsVersion>
    <!-- Check the default folder for the nuget version of the installer first, if that exists we should use that. -->
    <TscToolPath Condition="'$(TscToolPath)' == '' AND Exists('$(MSBuildThisFileDirectory)tsc\tsc.exe') ">$(MSBuildThisFileDirectory)tsc\</TscToolPath>
    <TscToolPath Condition="'$(TscToolPath)' == ''">$(MSBuildProgramFiles32)\Microsoft SDKs\TypeScript</TscToolPath>
    <TscToolExe Condition="'$(TscToolExe)' == ''">tsc.exe</TscToolExe>
    <TscYieldDuringToolExecution Condition="'$(TscYieldDuringToolExecution)' == ''">true</TscYieldDuringToolExecution>
</PropertyGroup>

Notice the 1st line in the configuration above has the value 1.7 for the TypeScript 1.7 compiler.请注意,上面配置中的第一行对于 TypeScript 1.7 编译器的值为1.7

Visual Studio 2015 IDE will use TypeScript that is specified in PATH. Visual Studio 2015 IDE 将使用在 PATH 中指定的 TypeScript。 If you can change it from TypeScript 1.7 to 1.8, it will work with ASP.NET 5 apps and other apps as will.如果您可以将它从 TypeScript 1.7 更改为 1.8,它将可以与 ASP.NET 5 应用程序和其他应用程序一起使用。

Don't need to use GULP, I hope your using VS IDE or its VS Code不需要使用 GULP,希望你使用 VS IDE 或者它的 VS Code

This approach will force all other applications to use TypeScript 1.8 only, however non ASP.NET 5 apps have entry in proj files.这种方法将强制所有其他应用程序仅使用 TypeScript 1.8,但非 ASP.NET 5 应用程序在 proj 文件中具有条目。

If you have the warning in Visual Studio:如果您在 Visual Studio 中收到警告:

Warning Your project does not specify a TypeScriptToolsVersion.警告您的项目未指定 TypeScriptToolsVersion。 The latest available TypeScript compiler will be used (xy).将使用最新的可用 TypeScript 编译器 (xy)。 To remove this warning, set TypeScriptToolsVersion to a specific version or "Latest" to always select the latest compiler.要消除此警告,请将 TypeScriptToolsVersion 设置为特定版本或“最新”以始终选择最新的编译器。

You can edit TypeScript Tools Version in your projects properties.您可以在项目属性中编辑TypeScript Tools Version You get this warning if you have the value for TypeScript version set to "None specified".如果您将TypeScript version的值设置为“未指定”,则会收到此警告。 Set it to "Use latest available" and the warning will go away.将其设置为“使用最新可用的”,警告就会消失。

在此处输入图片说明

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

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