Where can I find the TypeScript version installed in Visual Studio? - visual-studio

Maybe it's obvious, but I checked everywhere (besides the right place) and googled it. Nothing.

If you only have TypeScript installed for Visual Studio then:
Start the Visual Studio Command Prompt
Type tsc -v and hit Enter
Visual Studio 2017 versions 15.3 and above bind the TypeScript version to individual projects, as this answer points out:
Right click on the project node in Solution Explorer
Click Properties
Go to the TypeScript Build tab

Two years after the question was asked, using Visual Studio Command Prompt still did not produce right answer for me. But the usual Help|About window seems working these days:
UPDATE (June 2017):
VS 2013 does NOT show this info. (Later note: VS 2017 Enterprise edition does not show this info either).
VS uses Microsoft Build Engine (MSBuild) to compile Typescript files. MSBuild can support several major releases of Typescript, but About window shows only the latest one.
Here is how to get to the bottom of it:
A. To check which versions of Typescript are installed with your Visual Studio/MSBuild, inspect contents of C:\Program Files (x86)\Microsoft SDKs\TypeScript folder. For example, I have versions 1.0, 1.8 and 2.2:
B. Check which version of Typescript is requested by your project. In *.csproj file, look for <TypeScriptToolsVersion> tag, or you can add it if it is missing, like this
<PropertyGroup>
...
<TypeScriptToolsVersion>1.8</TypeScriptToolsVersion>
...
</PropertyGroup>
C. Finally, you can check, which version of Typescript is actually used by MSBuild. In TOOLS | Options | Projects and Solutions | Build and Run set MSBuild project output verbosity to Detailed:
Then build your project and inspect the output: you should see the reference to one of Typescript folders described in (A).

Based in the response of basarat, I give here a little more information how to run this in Visual Studio 2013.
Go to Windows Start button -> All Programs -> Visual Studio 2013 ->
Visual Studio Tools A windows is open with a list of tool.
Select Developer Command Prompt for VS2013
In the opened Console write: tsc -v
You get the version: See Image
[UPDATE]
If you update your Visual Studio to a new version of Typescript as 1.0.x you don't see the last version here. To see the last version:
Go to: C:\Program Files (x86)\Microsoft SDKs\TypeScript, there you see directories of type 0.9, 1.0 1.1
Enter the high number that you have (in this case 1.1)
Copy the directory and run in CMD the command tsc -v, you get the
version.
NOTE: Typescript 1.3 install in directory 1.1, for that it is important to run the command to know the last version that you have installed.
NOTE: It is possible that you have installed a version 1.3 and your code use 1.0.3. To avoid this if you have your Typescript in a separate(s) project(s) unload the project and see if the Typescript tag:
<TypeScriptToolsVersion>1.1</TypeScriptToolsVersion>
is set to 1.1.
[UPDATE 2]
TypeScript version 1.4, 1.5 .. 1.7 install in 1.4, 1.5... 1.7 directories. they are not problem to found version. if you have typescript in separate project and you migrate from a previous typescript your project continue to use the old version. to solve this:
unload the project file and change the typescript version to 1.x at:
<TypeScriptToolsVersion>1.x</TypeScriptToolsVersion>
If you installed the typescript using the visual studio installer file, the path to the new typescript compiler should be automatically updated to point to 1.x directory. If you have problem, review that you environment variable Path include
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.x\
SUGGESTION TO MICROSOFT :-) Because Typescript run side by side with other version, maybe is good to have in the project properties have a combo box to select the typescript compiler (similar to select the net version)

The tsc -v command run technically reads the TypeScript compiler version within the SDK directory set within the Windows Path variable. This doesn't necessarily reflect the latest version installed as the Path variable is not updated with subsequent installations.
The version that VS.NET uses to compile the TypeScript is what's in the project's configuration:
<TypeScriptToolsVersion>1.5</TypeScriptToolsVersion>
To help explain this more in detail I created the following post which has the specifics on the TypeScript versions installed, and which version VS.NET uses to compile the TypeScript files.
Which Version of TypeScript is Installed and Which Version is Visual Studio Using?
I also added a feature request on Microsoft Connect to make viewing and switching the TypeScript targeted version in VS.NET easier. This isn't really a TypeScript feature request as much as it is a VS.NET IDE enhancement.
Allow switching TypeScript configured version from Project Properties IDE

The TypeScript team sorted this out in Visual Studio 2017 versions 15.3 and later, including the free Community edition.
How to See Which TypeScript Versions are Installed in Visual Studio
All you now need do is to go to project properties of any TypeScript Visual Studio project (right-click the project file in Solution Explorer/Properties), then go to the TypeScript Build tab on the left-hand side. This has a 'Typescript version' dropdown that shows you the version the project is using, and if you open it the dropdown shows you ALL versions of TypeScript currently installed in Visual Studio.
The actual installs are currently at C:\Program Files (x86)\Microsoft SDKs\TypeScript and then subfolders by version number, at least on Win10 on my computer. If you want to see the exact version (e.g. 2.8.3 rather than just 2.8) you can find the appropriate tsc.exe in here and look at its properties (Details tab in right-click/Properties in File Explorer).
How to Install Specific TypeScript Version
If you want to install a specific version of TypeScript then these can be found on Visual Studio Marketplace, although specific version numbers can be a little difficult to find in that list. A Google search for, for example, 'visual studio marketplace typescript 3.3.1' will usually find the exact version you want. If you install from here and restart Visual Studio the version will appear in the dropdown. Note also that some of the latest versions of TypeScript (e.g. 4.2) will refuse to install if there's a more recent version installed.
Node.js Console Applications
This answer does not apply to the 'Node.js Console Application' project type, which doesn't have a TypeScript Build tab in project properties. This is because it uses a version of TypeScript installed in the project folder using npm. The version can be seen and changed in the package.json file, and when installed appears under the npm entry in Solution Explorer, and in the node_modules/typescript folder on disk.

On Visual Studio 2015 just go to: help/about Microsoft Visual Studio
Then you will see something like this:
Microsoft Visual Studio Enterprise 2015
Version 14.0.24720.00 Update 1
Microsoft .NET Framework
Version 4.6.01055
...
TypeScript 1.7.6.0
TypeScript for Microsoft Visual Studio
....

You can run it in NuGet Package Manager Console in Visual Studio 2013.

As far as I understand VS has nothing to do with TS installed by NPM.
(You may notice after you install TS using NPM, there is no tsc.exe file).
VS targets only tsc.exe installed by TS for VS extension, which installes TS to c:\Program Files (x86)\Microsoft SDKs\TypeScript\X.Y.
You may have multiple folders under c:\Program Files (x86)\Microsoft SDKs\TypeScript.
Set TypeScriptToolsVersion to the highest version installed.
In my case I had folders "1.0", "1.7", "1.8", so I set TypeScriptToolsVersion = 1.8, and if you run tsc - v inside that folder you will get 1.8.3 or something, however, when u run tsc outside that folder, it will use PATH variable pointing to TS version installed by NPM, which is in my case 1.8.10.
I believe TS for VS will always be a little behind the latest version of TS you install using NPM. But as far as I understand, VS doesnt know anything about TS installed by NPM, it only targets whateve versions installed by TS for VS extensions, and the version specified in TypeScriptToolsVersion in your project file.

I have VS2015 and I have to run a build with TypeScript 1.7, although I have 1.8 installed via npm install typescript -g there are two ways (at least for me they worked):
Go to your .proj file and add <TypeScriptToolsVersion>1.7</TypeScriptToolsVersion> as up as possible. Rebuild, re-run. If it doesn't work try 2.
Go to Control Panel -> System -> Advanced System Settings -> Enviroment Variables. Make sure you add your desired TypeScript version first: C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.7;C:\Users\serban\AppData\Roaming\npm
This will also affect your CLI:
$ tsc -v
message TS6029: Version 1.7.5

First, make sure you have the following address in your Environment Variables Path
C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.0
Then open your Command Prompt and type the following command:
tsc -v

You can do npm list | grep typescript if it's installed through npm.

Open a (normal, not the VS) command prompt or a PowerShell prompt.
tsc.exe -v
tsc.cmd -v
tsc -v
If you installed the same version of TypeScript for Visual Studio and using npm, the output from the above three commands should be the same.
If not, check your System PATH to see where in the path hierarchy and which typescript directory is listed. For PowerShell users, the easy way is:
$env:path -split ';'
Be careful of having nothing or multiple TypeScript directories listed in your System PATH variable. As of June 9, 2017, my System PATH looked like this (just the top part, which is all that matters in this situation):
ps>$env:path -split ';'
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.3
C:\nodejs\
C:\Users\{username}\AppData\Roaming\npm
Notice that only the 2.3 directory is included in the PATH, not multiple versions.

In the command prompt, simply type 1 of the following command then hit Enter :
tsc -v
or
tsc -version
or
tsc --version
Note: Make sure you have added Typescript to environment variable path
before running command, details here: How to set environment
variable.

For a non-commandline approach, you can open the Extensions & Updates window (Tools->Extensions and Updates) and search for the Typescript for Microsoft Visual Studio extension under Installed

If you'd like to find out what version of Typescript is being used on a particular project, go to your package-lock.json file. You will find something like this:
"typescript": {
"version": "3.5.3"
}

As of Visual Studio 2022, there is a new TypeScript/JavaScript project type for Angular/React/Vue, the TypeScript SDK is deprecated (but still installable through the VS installer with warnings), and Visual Studio supposedly provides IntelliSense and language support based on the TypeScript version you're using for your project (npm is the preferred way to specify the version of TypeScript you're using, via your package.json file).
Per this answer, though, there are still questions about how to control/discern what specific TypeScript language version Visual Studio 2022 is supporting at any given moment.

Related

How do I get bazel to use a specifc VC++ toolset?

I have a C++ project which uses Bazel as the build tool, and I am primarily developing on windows.
The latest visual studio toolset (VC++ 2017 version 15.9 v14.16 latest) no longer compiles my C++ code correctly (causes an internal compiler error) in the meantime I would like to continue using the previous toolset (VC++ 2017 version 15.8 v14.15 toolset). I am unsure of how to tell bazel which toolset it should use.
To be more specific. My BAZEL_VC variable is set to C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC. There are three folders in C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC, one of which is the latest version, two of which are previous versions. I would like to tell Bazel to use one of the previous version folders somehow.
I also can't seem to revert entirely back to the previous toolset. Nor can I remove the latest toolset while still having the older one function. Since windows views this as a responsibility of the build system, I turn to bazel.
It's the future and Bazel has fixed this issue and documented it better. See here.
set BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC
set BAZEL_VC_FULL_VERSION=14.16.27023

Dealing with Dual TypeScript installs

I'm trying to do some TypeScript tutorials but I'm hitting a weird problem. A while back I installed TypeScript 1.0.3.0 through Visual Studio here:
C:\Program Files (x86)\Microsoft SDKs\TypeScript
On the command line, when I check the TypeScript version it references that. I wanted to do some Angular (Angular version 2/4) so I loaded Node Package Manager and installed TypeScript through NPM. NPM loaded a newer version of TypeScript in another place on my computer. When I create Angular projects using Angular's CLI tool it somehow uses the NPM install. When I want to do simple, bare-bones TypeScript tutorials it uses the older version 1.0.3.0.
I lost my MSDN license so I can't run Visual Studio anymore. How do I update TypeScript that is in the Microsoft SDKs folder? Every Web site I check on installing or updating TypeScript tells me to use NPM.
If you don't plan to use it uninstall it, if you check Window uninstall software console panel page, you should find an item relating to that install.
If it's not there the simplest way would be to remove the old Typescript folder from your path variable (see here how to edit if you are not familiar). Look for the C:\Program Files (x86)\Microsoft SDKs\TypeScript folder and just remove it.
Then install the latest Typescript from npm.

"C:\Microsoft.Cpp.Default.props" was not found

I have a project created in Visual Studio, 2013.
The project file has the following properties:
ToolsVersion="12.0",
PlatformToolset = v120.
I have Visual Studio 2013 and Microsoft Build Tools 2015 installed.
This project gets successfully built using MSBuild 12.0. Upon the attempt to build it with MSBuild 14.0 I get an error
MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
As I understand, the problem is that the variable VCTargetsPath doesn’t get evaluated. If I specify the variable VCTargetsPath before the build (with the value C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120), the problem is solved.
However, this approach is not very convenient in case the path is different. Is it possible to somehow solve the problem in a more optimal way?
The registry key and its value:
HKLM\Software\WOW6432Node\Microsoft\MSBuild\ToolsVersions\12.0\VCTargetsPath $([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\V120\'))
This will usually solve the problem:
Run on an elevated command prompt (admin):
npm install --global --production windows-build-tools.
npm is required and my recommended package manager.
Change ownership of the install dir (in my case C:\Program Files (x86)\MSBuild\14.0) to your user, instead of admin. (properties>Security>Advanced).
Sometimes step 2 is unnecessary. It is still recommended to avoid having to use admin console for some commands.
I recently reinstalled Visual studio 2017 and encountered this issue while trying to install "npm java".
The fix for me is:
set ms version to 2017: npm config set msvs_version 2017
set VCTargetsPath environment variable to C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets
run command console as system administrator
These steps solved my issue:
Run npm install --global --production windows-build-tools
Run npm install --save nan
Set VCTargetsPath environment variable to C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140
For those using VS 2019:
set VCTargetsPath="C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160"
Edit (Sep 2020):
Sometimes it requires a trailing backslash (as bmiller mentioned below)
For those the above answer does not work, here is another possible solution to look at.
Even the installation of build tools or VS 2015 did not work for me. So I tried installing below directly via PowerShell (as admin)
https://chocolatey.org/packages/visualcpp-build-tools/14.0.25420.1
Command:
choco install visualcpp-build-tools --version 14.0.25420.1
Once this was installed, set an environment variable VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140
I solved this by:
Set VCTargetsPath environment variable to C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140
build using admin
I could not make it work with all the suggestions on this page
I downgraded nodejs to 10.15 and it worked fine
probably not the best answer but it works
When running MSBuild outside of Visual Studio 2019 (migrated from 2012), I had these kinds of problems.
I solved them running this MSBuild:
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild"
(customize it based on your VS version and target architecture) instead of this one:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild
that I was using when I had Visual Studio 2012.
I solved the problem by loading the solution in VS 2019 instead of double-clicking the solution name in File Explorer.
My specific problem was using "yarn install" and during the build process, it was trying to build the node_modules node-sass component using MSBuild, and failing.
I would get the following error: "error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk."
This makes sense on a new developer machine with only Visual Studio 2022 installed. After investigating the node-sass module's build\binding.sln file, it appeared indicate that it requires Visual Studio 2015 VC++ Build Tools.
I then downloaded the "Visual C++ Build Tools for Visual Studio 2015 with Update 3" DVD image from Microsoft. After I installed it, it seemed to solve the problem, no PATH or registry changes required. When I ran "yarn install" again, building the module node-sass completed properly.
First I went to the path and confirmed that I didn't have that file. I was able to get that file by
opening the Visual Studio Installer,
clicking on "Modify" of the current installation
selecting "C++ Clang-cl v142 build tools (x64/x86)" under the Individual Components" tab.
Confirm the installation by clicking the "Modify" button
I tried npm install and VCTargetsPath, all not work. Finally solved after it after upgrading visual studio to the latest version.
Resolved by installing Visual Studio Express 2015 for Windows 10.
This happened for me when I used node version 14.15.3, install Node Version Manager, install lower Node version (8.x.x for example), switch to it and that should solve the issue.
After calling VS2019's vcvarsall.bat, it is necessary to use VS2019's MSBuild instead of the one in C:\Windows.
set VCVARSALL=%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvarsall.bat
call "%VCVARSALL%" amd64
set MSBUILD=%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe
rem set MSBUILD=%FrameworkDir%\%FrameworkVersion%\msbuild.exe
In my case, the reason was that the system environment variable VisualStudioVersion was pointing to the removed version of Visual Studio.
The same solution was building ok from inside the Visual Studio but failed when building with the command-line MSBuild.
The problem was solved by changing the environment variable manually.
I have VS 2019 and I met the same problem trying to install module 'keytar' on Windows 10. This is what I did in order to solve the problem:
Opened "Visual Studio Installer" and removed extra 2017/2019 build tools (for example "Visual Studio Build Tools 2017", restarted the PC
Got back into "Visual Studio Installer" / "Visual Studio Professional 2019" / "Modify" and added "Desktop development with C++" workload
Got into project folder with my problem, removed node_modules folder
Opened CMDO
As #TheRennen suggested performed the command:
set VCTargetsPath=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\
(without quotation marks and with one backslash at the end)
run yarn command and now there were no errors.
I think now it a time to add VCTargetsPath into Windows env values.
node v14.19.0, npm 7.20.5, yarn 1.22.15
I have faced this issue while building my flutter application. The issue arises because of the program in my case flutter was unable to locate the file "Microsoft.Cpp.Default.props" which is required for building flutter apps in windows.
For solving the issue install MicroSoft Visual Studio(not Visual Studio code) from the below url.
https://visualstudio.microsoft.com/downloads/
Make sure to check the below option before starting installation.
After installation go to below directory.
C:\Program Files\Microsoft Visual Studio\2022\Community\Msbuild\Microsoft\VC
Note : I have installed community version of 2022 Visual Studio. The folder structure may be different based on your VS version
You can see few folders with version numbers
Open the folder and check which one have the "Microsoft.Cpp.Default.props" file . For my case it was the last folder v170. Open Environment variable and set "VCTargetsPath" variable with path to the folder in which "Microsoft.Cpp.Default.props" is present. Save path and restart the build process. This should work.
Make sure to use --global with the command in order to be able to use this package anywhere.
This solves the issue for me
While checking the .vcxproj file, I noticed the ToolsVersion was missing. I added it and it solves the issue.
Before :
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
After :
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

Typescript won't install into C:\Program Files (x86)\Microsoft SDKs\TypeScript'

My issue might be related to this one: No TypeScript compiler was found at C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe but I want to ask a different question.
When trying to install Typescript (currently 1.8.36) into Visual Studio 2013 or 2015, I don't see it installed into the Microsoft SDKs\Typescript folder. I'm pulling the install packages from http://www.typescriptlang.org, but I can't determine where the compiler gets installed and using 'where tsc' in Cmd isn't showing me anything useful. I know the latest releases of VS include TS, but they only go up to 1.8.10, and besides when trying to build my solution I get the issue I linked to, so something isn't right.
I've removed Productivity Tools and Web Essentials from both VS 2013 and 2015 and reinstalled TS but no luck.
So my question is how do I install the Typescript compiler into VS 2013 Update 5 or VS 2015 Update 3 such that MSBuild will find something at C:\Program Files (x86)\Microsoft SDKs\TypeScript\(TypescriptVersion) and compile my solution?
I ran into the same issue, the Typescript in SDKs directory comes once you install the extension into any version of Visual Studio. So to install Typescript version 1.8 do the following:
Open Visual studio
Click on Tools > Extensions and Updates
On the left side select, Online group
Search typescript
From the results select your desired version (in your case 1.8)
Click install, it will download a small web installer
Close the VS instance, and install the extension
Open your solution and try to build now
This should work just fine.

No TypeScript compiler was found at C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe

I installed Visual Studio 2015 and TypeScript 1.8.6 for Visual Studio 2015. After creating a new TypeScript project and building, I get this build error:
No compiler was found at C:\Program Files (x86)\Microsoft
SDKs\TypeScript\1.8\tsc.exe
Indeed, tsc.exe is missing in the file system.
Things I've tried:
Uninstall and re-install TypeScript Tools for Visual Studio 2015 1.8.6.0
Uninstall and re-install TypeScript Tools for Visual Studio 2013 1.8.5.0
Repair TypeScript Tools for Visual Studio 2015 1.8.6.0
I HAVE tried turning it off and on again :-)
Any clue on how to solve this? Which component installs the TypeScript SDK?
MSBuild is looking in the wrong place for tsc.exe
It should be looking in 'C:\Program Files (x86)\Microsoft SDKs\TypeScript\ tsc version \tsc.exe'
e.g. C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe
The one thing the TypeScript SDK installer wont do, is upgrade your existing projects. So all that reinstalling wont change anything. However, if you want MSBuild to use the newer compiler, you can upgrade your project yourself.
I don't think there is any way to do this through the UI, but it's easy enough to edit the Project file.
It needs to contain this in the first PropertyGroup
<TypeScriptToolsVersion>1.7</TypeScriptToolsVersion>
If you want the build to use v1.8.6, you need to set
<TypeScriptToolsVersion>1.8</TypeScriptToolsVersion>
In your case, I'm betting it's not there at all. So you should just add it.
I'm not experienced with using the TypeScript tools for Microsoft.. what you could do is use Gulp or Grunt tasks to compile TypeScript, this will even allow you to compile the TypeScript files everytime your save your .ts files.
You will need NPM (Node Package Manager) to install Gulp or Grunt and then install the package for compiling TypeScript.
You can find some information about the Grunt TypeScript package here: https://www.npmjs.com/package/grunt-typescript
Or for information about the Gulp TypeScript package, check this: https://www.npmjs.com/package/gulp-typescript
I've read through the comments on this issue on the TypeScript Github repo. Although this is a different issue, I did find a clue: repairing Visual Studio 2015 (through the Control Panel) installed tsc.exe in the correct folder.

Resources