How to edit the Typescript 1.4 “specified task exe

2019-02-16 19:50发布

问题:

I'm updating a project to use the latest versions of everything. I just updated the MVC 4 project from .Net 4.0 to .Net 4.5.1. I then updated the nuget packages(uninstalling some, and re-installing because they were based on .Net 4.0). Afterwords, I updated the machine version of Typescript to 1.4, that's when it all hit the fan. Just two simple errors. The first:

Your project file uses a different version of the TypeScript compiler and tools than is currently installed on this machine. No compiler was found at C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.4\1.4\tsc.exe. You may be able to fix this problem by changing the element in your project file.

I made sure this was set to "1.4"

 <TypeScriptToolsVersion>1.4</TypeScriptToolsVersion>

The second Error:

The specified task executable location "C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.4\1.4\tsc.exe" is invalid.

So I attempted to locate where the path was set and take out where is was trying to look in a second folder "1.4". The path should be:

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

I can't seem to find where this is set, and how I can change it.

I've tried:

Reinstalling and Repairing Typescript 1.4 and searching everywhere for where the path is set.

I've read answers that include checking the "Check your PATH environment variable." I can't find where to change that, and at this point my brain is angry.

I'm in Visual Studio 2013 Ultimate. Thanks.

回答1:

I had the same problem. Only way I found it just create a new folder '1.4' at C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.4 and copy to 'C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.4**1.4**' all files from parent directory.

Stupid solution, but it works for me.



回答2:

Solution:

  1. Go to C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio and rename the typescript folder inside your VisualStudio version. For example, I renamed Typescript folder inside v12.0.

  2. Go to C:\Program Files (x86)\Microsoft SDKs and rename typescript folder too.

  3. Go to Program and Feature in the control panel, search Typescript and repair Typescript.

This solution will fix the problem, now you can delete the renamed folders



回答3:

I installed version 1.5 then uninstalled it. After I uninstalled 1.5 I started to get the exact same error you are receiving. In order to fix it I had to run a repair in control panel on the Visual Studio installation. Running the repair on Visual Studio will fix the references to the SDK path.

I don't know if these steps are necessary, but before running the repair I manually went to:

C:\Program Files (x86)\Microsoft SDKs

and renamed the TypeScript folder.

Under the MSBuild path you may have multiple versions of Visual Studio listed. I went into each one and renamed the TypeScript folder.

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\

I then ran the repair on my installation of Visual Studio from control panel. If you don't want to run the repair on the full installation and you have the original installation media or iso you can run the TypeScript SDK and VS packages from:

H:\packages\TypeScript_SDK

H:\packages\TypeScript_VS

After you run the repair or run the packages individually you will have an old version of TypeScript installed and can now go into Visual Studio and use the Extensions and Updates dialog to install TypeScript 1.4.



回答4:

EDIT: I had further issues than this and found out that my project needed 1.0 I've therefore had to revert to this by uninstalling TypeScript, removing/renaming C:\Program Files\MSBuild\Microsoft\VisualStudio\v12.0\TypeScript and C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript and then running the repair option from the installer/uninstaller.


For me, I'd installed 1.5 and had a requirement to go back to 1.4. After going back to 1.4 I needed to amend

Microsoft.TypeScript.Targets

in

C:\Program Files\MSBuild\Microsoft\VisualStudio\v12.0\TypeScript\

Commenting out the append of TypeScriptToolsVersion from this

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

to this

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


回答5:

I was receiving this error in VS2013 too:

The specified task executable location "C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.4\1.4\tsc.exe" is invalid error.

Here is the solution that worked for me, from this GitHub comment by paulvanbrenk:

I think I have a fix which should go into 1.8 final.. however, in the mean time. Can you check the Microsoft.TypeScript.targets files in C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\TypeScript and see if there is a TscToolPath element, which appends the TypeScriptToolsVersion. Removing the TypeScriptToolsVersion from that element should fix the issue.



回答6:

1.4

The tools version is not the same as the compiler version. For 1.4 the version is 1.0 (I think).

I can't seem to find where this is set, and how I can change it.

It is set in your Microsoft.TypeScript.targets (location like : C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\TypeScript). Mine contains:

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

PERSONAL OPININONS: I don't use visual studio / msbuild and recommend you invest in an OSS editor like atom (disclaimer: maintainer) and a build pipeline like grunt OR gulp.



回答7:

This was a bug with TypeScript which has allegedly been fixed. The bug duplicated the TypeScript version in the path.

Reference: https://github.com/Microsoft/TypeScript/issues/3493

Note: There is a similar issue now if you are trying to build with Visual Studio Online. According to that same thread, the VSO team is aware and working on a fix...