2017-06-21 27 views
0

我已經安裝了打字稿編譯器和MSBUILD到項目中。 這是一個dotnet的核心項目(的csproj)目標框架4.6.1儘管從nuget安裝,msbuild + visual studio執行錯誤的打字稿版本

`.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的

<ItemGroup> 
    <PackageReference Include="Microsoft.TypeScript.Compiler" Version="2.3.3" /> 
    <PackageReference Include="Microsoft.TypeScript.MSBuild" Version="2.3.3" /> 

中的NuGet包然而,當我使用建的Visual Studio 2017年,或msbuild我得到錯誤,因爲使用了錯誤的編譯器版本。

如何在IDE或者禁止建設打字稿及的MSBuild完全(我用的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版本。

+0

btw如果你想通過WebPack完成TS編譯,爲什麼要包含那些NuGet包?我假設編譯器會通過npm被拉進來 –

+0

我使用visual studio來編輯打字稿文件,並且在IDE中顯示錯誤/警告很有用,我不確定我會怎麼做呢? – Jim

回答

0

列入VS進口指標允許編譯通過在csproj文件中使用

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> 

被禁用。

要挾打字稿編譯器使用附帶的2.3版本Microsoft.Typescript.Compilercsproj文件中使用

<TypeScriptToolsVersion>2.3</TypeScriptToolsVersion> 

相關問題