【发布时间】:2017-06-21 14:55:19
【问题描述】:
我已将 typescript 编译器和 MSBUILD 安装到项目中。 这是一个针对框架 4.6.1 的 dotnet 核心项目 (csproj)
`.csproj file...`
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>Ignite.Web</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>Ignite.Web</PackageId>
<CodeAnalysisRuleSet>..\Ignite.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\net461\Ignite.Web.xml</DocumentationFile>
<CodeAnalysisRuleSet>..\Ignite.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
...
该文件还包含用于编译器和 msbuild 的 nuget 包
<ItemGroup>
<PackageReference Include="Microsoft.TypeScript.Compiler" Version="2.3.3" />
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="2.3.3" />
然而,当我使用 Visual Studio 2017 或 msbuild 构建时,由于使用了错误版本的编译器,我得到了错误。
我该如何在 IDE 和 msbuild 中完全禁止构建 typescript(我仍然在使用 webpack),或者修复路径?
PreComputeCompileTypeScriptWithTSConfig:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\tsc.exe --project "C:\Projects\Github\Ignite\Ignite.Web\tsconfig.json" --listEmitted
Files
CompileTypeScriptWithTSConfig:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\tsc.exe --project "C:\Projects\Github\Ignite\Ignite.Web\tsconfig.json" --listEmitted
Files
从输出中可以看出,当我执行 msbuild 时,它使用的是 2.2 版本。
【问题讨论】:
-
顺便说一句,如果您希望通过 WebPack 完成 TS 编译,为什么还要包含这些 NuGet 包?我假设编译器将通过 npm 引入
-
我使用 Visual Studio 编辑打字稿文件,在 IDE 中显示错误/警告很有用,我不知道我该怎么做?
标签: typescript msbuild visual-studio-2017