VSTS Specified TypeScript compiler not found - visual-studio

I am using VSTS for a project that is using TypeScript. We have a CI Build configured and suddenly that one stopped working today. Yesterday all was fine, today they are all failing.
Looking into the build logs I discovered that it's not finding the TypeScript compiler that we specified:
Warning : Your project specifies TypeScriptToolsVersion 2.1, but a matching compiler was not found. The latest available TypeScript compiler will be used (2.4). To remove this warning, install the TypeScript 2.1 SDK or update the value of TypeScriptToolsVersion.
So all of a sudden it starts compiling with TypeScript 2.4 and we have some code that's not compatible with that version (Promises).
I have defined the TypeScript Tools Version in our .csproj as
<TypeScriptToolsVersion>2.1</TypeScriptToolsVersion>
and that seems to be working as I read in the build logs that it tried using that one first.
Any idea what caused VSTS suddenly to "forget" about TypeScript 2.1 and how I can fix this? I could not find any update notification or anything.

Right click on Project and click properties
Click on TypeScriptBuild and Select Use Latest Available

That means the TypeScript SDK has been updated on build server. If you are using private build agent, you can check it on your build server. If you are using Hosted agent, it will be updated irregularly (official article isn’t updated)
Regarding this issue, you can refer to these threads:
For VS 2015 project (Microsoft.TypeScript.MSBuild package): Visual Studio Team Services build Typescript error
For VS 2017 project (Microsoft.TypeScript.MSBuild package): Angular4.1 with .NET Core1.1 build fails in VSTS Hosted VS2017 agent

Related

Visual Studio 2019 - MSBuild tools version 12 missing

I'd like our developers to use one version of Visual Studio for all of our projects (where possible) - to that end, I've asked them to use VS2019 for some projects that were originally created in VS2010 and then migrated to VS2013.
A runtime behavior change occurred when running one of these old webforms applications in VS2019. I'm not sure why it's different since the dlls being used are the same and the compiled IL is the same for the method in question, but at the moment I don't really care about "fixing" it since it would require making code changes and regression testing the entire application; a path I'd like to avoid for the moment.
What I'd like to do is make sure VS2019 builds with the indicated tools so that we retain the old behavior. The project file is referencing tools version 12 (VS2013 is not installed), but when Visual Studio builds I see the following in the MSBuild output:
Project file contains ToolsVersion="12.0". This toolset may be unknown or missing, in which case you may be able to resolve this by installing the appropriate version of MSBuild, or the build may have been forced to a particular ToolsVersion for policy reasons. Treating the project as if it had ToolsVersion="Current". For more information, please see http://go.microsoft.com/fwlink/?LinkId=293424.
I installed MSBuild Tools 2013, but that didn't correct the issue before or after a restart. I also tried with tools version 15 and got the same error (VS2017 is installed).
MSBuild from the VS2019 dev command prompt worked, but I had to copy the 14.0 webapplication targets to a new folder named "16.0". I'm not sure why there is a 14.0 folder but no 12.0 or 15.0 folder without doing more searching online.
Is this a fool's errand, or am I missing something simple?
MSBuild from the VS2019 dev command prompt worked, but I had to copy
the 14.0 webapplication targets to a new folder named "16.0". I'm not
sure why there is a 14.0 folder but no 12.0 or 15.0 folder without
doing more searching online.
Update 1
This is just a prompt warning to ensure that you'd better use the related MSBuild version to build the project. It is designed as a reminder message.
But in fact, MSBuild does add backward compatibility feature.
The message is just a warning rather than an error and will not break the build process. And if it breaks the build process, it can prove that backward compatibility is not supported.
You can test it: use VS2019 to build a VS2017 or VS2015 projects and I am sure that it can built them successfully.
==============================================
Each version of VS creates a project that is built for the corresponding MSBuild version.
For example, in the project created in VS2010, its ToolsVersion="4.0", so when you use MSBuild from VS2010(msbuild v4.0), it will built without that warning.
VS2013-->ToolsVersion=12.0 , VS2015-->ToolsVersion=14.0 , VS2017-->ToolsVersion=15.0, VS2019--> ToolsVersion=Current
So when you build the project, you should try the related msbuild version to build them.
Although MSBuild supports backwards compatibility, the problem is always in the form of a warning, which has been troubling us during the project migration.
Solution
To solve it, you should use the related MSBuild to build the project with the corresponding ToolsVersion.
If you want to build them in VS2017, you should change ToolsVersion to 15.0 in every project's xxx.xxproj file.
If you want to build them in VS2019, you should change ToolsVersion to Current in every project's xxx.xxproj file.
More info, you can refer to my answer in this similar issue.

Build Definition Not Building After Nuget package Update In Visual Studio

I inherited a lot of stuff that is above my knowledge level, but I am the only one here that is close enough to that level to figure it out. I feel like I learn quickly, and I have been able to jump every hurdle so far without too much time taken, but I just can't figure this out!
Basically we use TFS 2015 and in that we have a build definition that goes through an agent on a remote computer (that I can remote into).So, one of the developers checked in code with an updated NuGet package (Newtonsoft.Json) and it broke the build. The files and everything build locally just fine, but the build bot is broken.
I have a screenshot on imgur for a little context in my build definition and the webhook we use to send the notification in slack links to a an error page that tells me "error: Build Not Found" so I am all kinds of confused and I can't find anything online that can help me.
EDIT:
In my build logs I got this error
Error CS0246: The type or namespace name 'DataSourceRequest' could not be found (are you missing a using directive or an assembly reference?)
All of my other branch builds work and the only difference is that I updated the nuget package. Is there any way for me to upgrade the nuget package in the build agent?
Screenshot of Build Definition:
Build Definition Not Building After Nuget package Update In Visual Studio
AFAIK, the reason of this issue may be that you upgraded the package Newtonsoft.Json to version 9.01 or higher.
Starting from Newtonsoft.Json 9.0.1, this package supports the targets framework .NETStandard:
https://www.nuget.org/packages/Newtonsoft.Json/9.0.1:
Which is supported by NuGet 2.12 for Visual Studio 2013:
NuGet 2.12 Release Notes
Full NetStandard and NetCoreApp support for VS2013.
So, to resolve this issue, you should make sure the nuget.exe version is higher than 2.12 and the Visual Studio version is high than 2013.
Besides, as we know, Visual Studio are backwards compatible. Meaning we could use the lower version Visual Studio to develop the project and we could build it with a higher version of Visual Studio on the agent. But if the other way around, develop it with higher version, build it with lower version on the agent, we may encounter some issues due to compatibility. So, If we keep that the Visual Studio version on the agent is higher than the version you are developing, it would be better.
Hope this helps.

TypeScript version mismatch in Visual Studio 2019

I am thoroughly confused by Typescript versioning as it relates to Visual Studio 2019. I have a .NET Core 2.2.x project which utilizes Typescript. When I edit any .ts file, I get the following warning (in the error list):
Your project is built using TypeScript 3.4, but the TypeScript language service version currently in use by Visual Studio is 3.4.3. Your project may be using TypeScript language features that will result in errors when compiling with this version of the TypeScript compiler. To remove this warning, install the TypeScript 3.4.3 SDK or update the TypeScript version in your project's properties.
It claims that my project is built using TypeScript 3.4, but package.json specifically lists "typescript": "3.4.3".
Then it asks to install TypeScript SDK 3.4.3, which I have from here. I also npm install -g typescript previously, so running tsc -v yields Version 3.4.3.
What am I missing?
I had a similar problem as you describe but in the Task Runner Explorer.
Assumptions: TypeScript is should be in your PATH variables (you can check by running 'tsc -v' from a normal command prompt.
Since quite a while, Visual Studio allows you to choose the TypeScript version to use on a per-project basis (right-click project => Properties => tab 'Typescript Build'). Here you could choose an officially installed version but also 'Use latest available'.
In Visual Studio Options you can specify the locations and order in which 'External Web Tools' are used when building web projects using 3rd party tools. In that list, you will probably find an item '$(PATH)'. I moved it to the top of the list, which makes the globally installed TypeScript version the first to be found when searching for it.
I hope this applies for your situation as well.
This may have gotten easier since the original answer.
Now you can just install NuGet package Microsoft.TypeScript.MSBuild.
Then you don't need to install the SDK separately and it is recommended by Microsoft to use NuGet or npm:
https://learn.microsoft.com/en-us/visualstudio/javascript/javascript-in-vs-2019?view=vs-2019
In the project Properties > Typescript Build tab, the Typescript version will change to n.n (NuGet) and will be grayed out. Now if you work on a team, all team members will be certain to have the same version for this project! Cool!

Working with different versions of a project, that has been built with different versions of Typescript

I'm currently part of a team that is working on a rather large Typescript project in Visual Studio. As time has gone by and different versions of the project has been released, we've run into a snag when it comes to the versioning of Typescript installed together with Visual Studio.
Scenario:
v 1.1.0 of product released, built on TypeScript 1.8
v 1.2.0 of product released, built on TypeScript 2.1
A bug from customer X is reported for the 1.1.0 version, and the team will start working on a fix.
Problem:
Visual Studio is currently configured to use the latest version of TypeScript (2.1 in this case), so the code from v 1.1.0 does not compile.
Yes, I can manually change typescript versions in the project file and move around on tsc.exe to make this work. Typescript is installed globally as well, but for some reason, they decided that Visual Studio will install the compiler in its own folder instead of acessing the globally installed one.
Hoping someone else has run into this problem, and have a better approach to this.
This was solved by adding the following parameter to my .csproj file:
<TypeScriptCompileBlocked>True</TypeScriptCompiledBlocked>
Ended up running a grunt watch task, using the globally installed TypeScript compiler to compile the project.
Fetched from the official TypeScript docs
If you are using a different build tool to build your project (e.g. gulp, grunt , etc.) and VS for the development and debugging experience, set true in your project. This should give you all the editing support, but not the build when you hit F5.

The TypeScript compiler couldn't be found

I am using Visual Studio 2012 and TypeScript version 0.9.5. I am also using web essentials 2.8. After I try to save the TypeScript file, it says:
Compile Error.
See error list for details
The TypeScript compiler couldn't be found. Download http://www.typescriptlang.org/#Download
But even downloading latest version did not help. I checked some links but could not find the solution.
Right side panel of TypeScript files doesn't update properly
Cannot compile TypeScript files in Visual Studio 2012
Please help.
Thanks !!!
You are using a really old version of web essentials with a new version of TypeScript. WebEssentials reduced its typescript support after v3.x so as to not conflict with Visual Studio tooling for TypeScript.
You can get the latest WebEssentials here : http://vswebessentials.com/download
I also had the error message "The typescript compiler couldn't be found".
I had an older version of Web Essentials and when I installed version 3.7 the error message dissapeared but no js files where created.
Then in: Tools->Options->Text Editor->Typescript->Project
I checked "Compile on Save" (Automatically compile TypeScript files which are not part of a project) and then the js file got compiled.
Also when I look at the properties of the typescript file I now see TypeScriptCompile in Build Action. When I had the older version of Web Essentials I did not have the option "TypeScriptCompile" in Build Action.

Resources