Typescript: The "VsTsc" task could not be initialized with its input parameters. (after upgrade to VS 2017.15.6.1)

Created on 9 Mar 2018  ·  57Comments  ·  Source: microsoft/TypeScript

Search Terms:
VsTsc, Build , 2017

Expected behavior:
Be able to build my AspNetCore 2 web application without errors

Actual behavior:
2 errors displayed after build attempt:

  • Error MSB4063 The "VsTsc" task could not be initialized with its input parameters. Jbssa.Feedlot.Web C:\Program Files (x86)\Microsoft SDKsTypeScript\2.5\build\Microsoft.TypeScript.targets 196
  • Error MSB4064 The "ComputeOutputOnly" parameter is not supported by the "VsTsc" task. Verify the parameter exists on the task, and it is a settable public instance property. Jbssa.Feedlot.Web C:\Program Files (x86)\Microsoft SDKsTypeScript\2.5\build\Microsoft.TypeScript.targets 207

I was asked to include the following tsconfig.json file in my project in a previous issue.

{
    "compilerOptions": {
      "allowJs": true,
      "noEmit": true,
      "declaration": false
    },
    "include": [
      "wwwroot/js"
    ],
    "exclude": [
      "lib"
    ]
  }

And this is my csproj file for the failing web project.

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <ApplicationIcon>wwwroot\favicon.ico</ApplicationIcon>
    <AssemblyName>Jbssa.Feedlot.Web</AssemblyName>
    <RootNamespace>Jbssa.Feedlot.Web</RootNamespace>
    <TypeScriptToolsVersion>2.5</TypeScriptToolsVersion>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="3.2.0" />
    <PackageReference Include="BuildBundlerMinifier" Version="2.6.362" />
    <PackageReference Include="Core.ExceptionTranslation" Version="2.0.18052.1" />
    <PackageReference Include="Core.Mvc" Version="2.0.18038.1" />
    <PackageReference Include="FluentValidation.AspNetCore" Version="7.5.0" />
    <PackageReference Include="Flurl.Http" Version="2.2.1" />
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.2" />
    <PackageReference Include="Serilog.Settings.Configuration" Version="2.5.0" />
    <PackageReference Include="Serilog.Sinks.Async" Version="1.1.0" />
    <PackageReference Include="Serilog.Sinks.File" Version="4.0.0" />
    <PackageReference Include="Serilog.Sinks.Literate" Version="3.0.0" />
    <PackageReference Include="Serilog.Sinks.Seq" Version="4.0.0" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Jbssa.Feedlot.Core\Jbssa.Feedlot.Core.csproj" />
    <ProjectReference Include="..\Jbssa.Feedlot.BusinessLogic\Jbssa.Feedlot.BusinessLogic.csproj" />
    <ProjectReference Include="..\Jbssa.Feedlot.Security\Jbssa.Feedlot.Security.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Folder Include="wwwroot\js\BunkCall\" />
  </ItemGroup>

  <ItemGroup>
    <Content Update="wwwroot\js\BunkCall\DropsRationPercent.js">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

</Project>

Please note that deleting the tsconfig.json file from the project allowed it to build successfully, and the older issue complaining about too many files for intellisense is not present either. Therefore I assume that the underlying issues with VS2017 and compling ts files is fixed and doesn't need the config file anymore. This would have been nice to read in the Release Notes.

Bug Fixed Visual Studio

Most helpful comment

Here's my analysis of this problem:

When does this error come up?

Once scenario (which is hitting us hard) where this error comes up when the highest effective TypeScriptToolsVersion >= 2.6 and the lowest is <= 2.5 across all TypeScript enabled projects in the currently loaded solution. We have this because we are incrementally upgrading projects from 2.4 to 2.7 and can't do this big bang primarily because noUsedLocals has become stricter and requires code changes to make it comply with the stricter model.

Why does this error come up?

In version 2.6, the ComputeOutputOnly property for the VsTsc task (the task that's defined in Microsoft.TypeScript.Tasks.dll and is responsible for invoking the actual TypeScript compiler) was renamed to ComputeInputAndOutputOnly. Although Visual Studio has all the plumbing in place to try and load Microsoft.TypeScript.Tasks.dll from the right folder, if/once the 2.7 DLL gets loaded, attempts to load the 2.4 DLL result in that same DLL being used which doesn't have the ComputeOutputOnly property. This is in turn because their TypeNames, including their AssemblyVersion, are same but their public signature (and code) is obviously different. It seems the actual DLL loaded (first) is based on the highest TypeScriptEffectiveToolsVersion rather than which project is compiled first which is why the error is always about the missing old property rather than the missing new property.

Workaround we've implemented

  1. Close all instances of VS2017.
  2. Go to the C:\Program Files (x86)\Microsoft SDKsTypeScript\2.7\build folder using Windows Explorer.
  3. Rename the TypeScript.Tasks.dll to TypeScript.Tasks.dll.27 and Microsoft.TypeScript.targets to Microsoft.TypeScript.targets.27.
  4. Change 2.7 in the address bar to 2.4 to get to the equivalent folder for 2.4.
  5. Copy TypeScript.Tasks.dll and Microsoft.TypeScript.targets from there, press back and paste them in the 2.7 folder. Note that these are only the "Tasks" DLL and the targets file but not the actual compiler. The DLL must match the targets file.

Closing remarks

This is a general .NET limitation that two assemblies with the same TypeName can't be loaded in the same process (AppDomain+LoadContext to be more specific) so this is a fundamental flaw/shortcoming in the concurrent-multi-version support for TypeScript. The official fix would probably have to be at least assign these Tasks assemblies a different AssemblyVersion for each TypeScript release. Once again, our workaround downgrades only the VsTsc task but the actual compiler (tsc.exe) will still be picked based on the TypeScriptToolsVersion in the project allowing us to upgrade each project on its own schedule.

All 57 comments

I had the same issue after the update to 2017.6.1, but had seen something like that before, also related to TSC build target files. So I suspected a change in the vstsc task lib (Typescript.Tasks.dll).
Commenting out the parameter ComputeOutputOnly in Microsoft.TypeScript.targets made the build work again.

Edited.
I thought it worked. However, even though the tasks.dll has the ComputeOutputOnly parameter, the build sometimes complains about it not existing, and sometimes works fine. Very weird.

Any solutions on this so far ??

For me, commenting out ComputeOutputOnly in the targets file works most of the time. It's still a bit weird, as the tasks dll actually has that property, so I can only imagine that the wrong dll is loaded at some point in the build process. But it probably can't be called a real solution.

I have the same problem using typescript 1.8.11

Hello all,
This seems to be a related issue to the one discussed at https://github.com/Microsoft/TypeScript/issues/18335#issuecomment-358391454

We are actively working on ways to address this issue in general, but for now, closing VS, ensuring that any and all MSBuild.exe processes are killed, and reopening VS should resolve the issue. Please let me know if it does not, and I would be happy to investigate further.

Thank you!
Ben Lichtman
TypeScript Language Service Engineer

Just upgraded to 15.6.2 and got the same issue, updated the Microsoft.TypeScript.Compiler and Microsoft.TypeScript.MSBuild nuget packages and it resolved the issue!

Reopening VS doesn't seem to consistently fix the issue. I restarted my machine (to make sure), and it fixes the issue initially but when I clean the solution it seems to break it again. The only solution we can find to consistently eliminate this message is to exclude the tsconfig file from our project, but that causes other issues long term.

@mikecole I apologize for the difficulty you are having. Would you be willing to send me a build log with diagnostic verbosity? This will help me figure out a better solution than needing to exclude your tsconfig, which we certainly don't want you to have to do.

@uniqueiniquity It's not a huge deal... no apologies needed.

I'll check on the build log to see if it's OK to share.

We're not using TypeScript so the only reason we included the tsconfig file was to eliminate the "Language service is disabled" error message issue. If this is no longer needed we can live with that solution.

I have VS version 2017.15.6.2

For solutions, install or update lasted nugget package from current project:

TypeScript.MSBuildTask
Microsoft.TypeScript.Compiler
Microsoft.TypeScript.MSBuild

This just started breaking my builds using hosted build server 2017. Same code that build fine last week no longer builds and gives this error on my asp.net web sites. I'm explicitly using 2.3.3 typescript specified by nuget package and in the csproj file. Locally, builds fine. When I try to build on the hosted machines, it fails. I upgraded my local to have latest typescript compiler

<package id="Microsoft.TypeScript.Compiler" version="2.7.2" targetFramework="net462" developmentDependency="true" />
<package id="Microsoft.TypeScript.MSBuild" version="2.7.2" targetFramework="net462" developmentDependency="true" />

and now i'm seeing the failure locally. I believe the build server is not respecting the specified version and is trying to use latest. :(

@spelltwister Could you send me a build log with diagnostic verbosity from the build server? I'm surprised that it's ignoring your request to use version 2.3.3, so I'd like to investigate that further.

Updated to latest:

Microsoft.TypeScript.Compiler
Microsoft.TypeScript.MSBuild

Still same issue

It worked for me after upgrading TypeScriptToolsVersion from 2.3 to 2.4

upgrading one of my projects to 2.6 typescript worked fine. however, the other project will not update properly for some reason and will not build still. I created a private build server with 15.5.3 installed and it is able to build the project that will not build on VSTS hosted.

@shyamal890 Are you still seeing this issue after closing VS and all MSBuild.exe processes? If so, could you send me a build log with diagnostic verbosity?

Same problem on VSTS hosted build system for us. Our Typescript version is currently set to 2.3 in the csproj and builds fine locally using the latest VS 15.6.3 (and was also fine on 15.6.2 twenty minutes earlier). Upgrading to 2.4 causes build errors on my dev machine so I'll have to fix those before trying the build machine again.

I was able to fix this by going to my project properties, clicking 'TypeScript Build' and changing the TypeScript version to 'Use latest available'.

This essentially changes the tag in the .csproj file to the value of 'Latest', which in my case is 2.6. Previously I was explicitly targeting 2.5.

Unfortunately this doesn't work for us (using latest Typescript) as this causes build issues with Kendo UI typings. Upgraded to the latest Kendo UI but still no joy. From the looks of it we won't be able to do automated VSTS builds until this is corrected so it's a pretty serious issue for us.


From: advocoates notifications@github.com
Sent: 21 March 2018 16:25:46
To: Microsoft/TypeScript
Cc: Roger Dawson; Comment
Subject: Re: [Microsoft/TypeScript] The "VsTsc" task could not be initialized with its input parameters. (after upgrade to VS 2017.15.6.1) (#22422)

I was able to fix this by going to my project properties, clicking 'TypeScript Build' and changing the TypeScript version to 'Use latest available'.

This essentially changes the tag in the .csproj file to the value of 'Latest', which in my case is 2.6. Previously I was explicitly targeting 2.5.


You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com/Microsoft/TypeScript/issues/22422#issuecomment-375004601, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABWODeplnv7KLmP64wH0DcSKq4wj67bmks5tgn8KgaJpZM4SjnwM.

@RogerDawson Could you send me a build log with diagnostic verbosity from the build server? I'm surprised that it's ignoring your request to use version 2.3, so I'd like to investigate that further.

@RogerDawson You may need to add /v:diag to your MSBuild arguments in your build definition to get the proper level of logging.

@RogerDawson disregard my previous request; I now understand why it seems to be ignoring TS 2.3.
Since the VSTS hosted agent won't always have the right version of TypeScript installed, their recommendation is to use the NuGet package available at https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild/ as discussed at https://developercommunity.visualstudio.com/content/problem/168235/typescript-build-started-failing-over-the-weekend.html for example.

We're having the exact same issue when building/publishing locally in Visual Studio 2017 and we're not even using typescript with no typescript config file in the project that I can find.

@uniqueiniquity My project does use nuget packages to specify the TS version.
@dreggas My project that doesn't use typescript also failed, but worked after updating to 2.6 typescript version.

@dreggas and @spelltwister, could you both send me build output with diagnostic verbosity? I would be happy to look into both issues.

Hi @uniqueiniquity , thanks for replying. I did try adding the nuget packages but it still doesn't work. Specifically I added the following to my csproj:

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

And I still get the following errors in VSTS:

_2018-03-21T16:24:29.5241741Z (PreComputeCompileTypeScriptWithTSConfig target) ->
2018-03-21T16:24:29.5242227Z C:\Users\VssAdministrator.nuget\packages\microsoft.typescript.msbuild\2.3.3\tools\Microsoft.TypeScript.targets(203,7): error MSB4064: The "ComputeOutputOnly" parameter is not supported by the "VsTsc" task. Verify the parameter exists on the task, and it is a settable public instance property. [D:\a\1\s\Dashboard\Dashboard.csproj]
2018-03-21T16:24:29.5242865Z C:\Users\VssAdministrator.nuget\packages\microsoft.typescript.msbuild\2.3.3\tools\Microsoft.TypeScript.targets(192,5): error MSB4063: The "VsTsc" task could not be initialized with its input parameters. [D:\a\1\s\Dashboard\Dashboard.csproj]_

The build was attempted three times with the <TypeScriptToolsVersion>2.3.3</TypeScriptToolsVersion> set to 2.3, 2.3.3 and removed but each time failed with the same errors as above. Before I added the nuget packages the path in the error seemed to refer to version 2.3 of Typescript (see below) so I'm not sure how it can be using the wrong version of typescript, going by the path at least:

_2018-03-21T13:17:50.9642341Z (PreComputeCompileTypeScriptWithTSConfig target) ->
2018-03-21T13:17:50.9643302Z C:\Program Files (x86)\Microsoft SDKsTypeScript\2.3\build\Microsoft.TypeScript.targets(202,7): error MSB4064: The "ComputeOutputOnly" parameter is not supported by the "VsTsc" task. Verify the parameter exists on the task, and it is a settable public instance property. [D:\a\1\s\Dashboard\Dashboard.csproj]
2018-03-21T13:17:50.9644017Z C:\Program Files (x86)\Microsoft SDKsTypeScript\2.3\build\Microsoft.TypeScript.targets(191,5): error MSB4063: The "VsTsc" task could not be initialized with its input parameters. [D:\a\1\s\Dashboard\Dashboard.csproj]_

Our last good build was on the 15th and the same area of the build produced the following output:

_2018-03-15T13:44:45.4299322Z PreComputeCompileTypeScriptWithTSConfig:
2018-03-15T13:44:45.4300139Z C:\Program Files (x86)\Microsoft SDKsTypeScript\2.3\tsc.exe --project "D:\a\1\s\Dashboard\Scripts\tsconfig.json" --listEmittedFiles
2018-03-15T13:44:45.4371799Z CompileTypeScriptWithTSConfig:
2018-03-15T13:44:45.4372283Z C:\Program Files (x86)\Microsoft SDKsTypeScript\2.3\tsc.exe --project "D:\a\1\s\Dashboard\Scripts\tsconfig.json" --listEmittedFiles_

What's interesting is the line that precedes the errors and the commands that produce the errors, as it is different to the last healthy build and seems to suggest things are now being built differently perhaps?

Many Thanks,

Roger

TypeScript.MSBuildTask does not include targets for VS version 15, see here, so installing that package broke our build.

Hi @wburgers , I removed TypeScript.MSBuildTask from the csproj but the build is still broken. Same error as before.

@uniqueiniquity I've managed to fix the Kendo issues and upgrade our project to 2.6.2 but it still doesn't build in VSTS. Same error, although the paths now show 2.6.2, rather than 2.3 or 2.3.3.

@wburgers, I don't think you should need TypeScript.MSBuildTask unless you are trying to use TS 1.4. All you need is the package Microsoft.TypeScript.MSBuild, which is designed to work with Visual Studio 2015 and Visual Studio 2017.

@RogerDawson You should also remove Microsoft.TypeScript.Compiler; it's a subset of Microsoft.TypeScript.MSBuild.

I know @uniqueiniquity, but it was suggested by @eaguerrerov. So I'm just saying that that is not a helpful suggestion...

Hi @uniqueiniquity , so I now only have the Microsoft.TypeScript.MsBuild package version 2.6.2 and I still get the error:

_2018-03-22T16:05:14.8758935Z (PreComputeCompileTypeScriptWithTSConfig target) ->
2018-03-22T16:05:14.8759677Z C:\Users\VssAdministrator.nuget\packages\microsoft.typescript.msbuild\2.6.2\tools\Microsoft.TypeScript.targets(208,7): error MSB4064: The "ComputeOutputOnly" parameter is not supported by the "VsTsc" task. Verify the parameter exists on the task, and it is a settable public instance property. [D:\a\1\s\Dashboard\Dashboard.csproj]
2018-03-22T16:05:14.8760818Z C:\Users\VssAdministrator.nuget\packages\microsoft.typescript.msbuild\2.6.2\tools\Microsoft.TypeScript.targets(197,5): error MSB4063: The "VsTsc" task could not be initialized with its input parameters. [D:\a\1\s\Dashboard\Dashboard.csproj]_

I did a bit of digging on the hosted build agent and it suggested that Typescript 2.0, 2.1 and 2.2 are installed on the Hosted 2017 agent which is strange, given we've been running with 2.3 for a year or so now. Here is the link: VSTS image definition on GitHub . This is muddying the waters even more though so I think I'm going to ignore what the readme says.

To top my day off I can't publish from my local dev PC anymore due to a completely different publishing error (worked a few weeks ago so I can only assume the latest versions of VS 2017 have caused this 15.6.0-15.6.3 I guess). Frustrating to say the least.

Thanks for the help so far though

I'm not sure what you need from me exactly. my logs are the same as above. if you need something more, i can try to provide it, but have you tried running a project targeting, for example, the 2.3.3 typescript version and building it on the hosted vs2017 agent? all of my projects for different companies broke so i would imagine it easy to reproduce. and it's been going on so long that we've had to scramble for different build / deploy options. One place we did the private build servers, another we're building locally and pushing from studio on machines that still compile. what a mess :(

@RogerDawson and @spelltwister I sincerely apologize for all the trouble this is causing you.
There was a publishing error that was introduced in 2.6.x that was resolved in 2.7.2, so upgrading further may help.
I too am surprised that TS 2.3 was consistently working in the build agent without relying on a NuGet package.
However, these most recent messages do confirm the issue that you're seeing; the wrong version of the DLL is being loaded even though it's part of the NuGet package. We're looking into this now, since this definitely should not be happening.

Hi @uniqueiniquity , I think the publishing error is something completely different. I've reverted back to my original 2.3 code and it still happens so I'm guessing something has gone wrong with the quick succession of VS 2017 15.6.x releases - starting to wish I had a VM of a build server with snapshots now, like we would have in the past before VSTS.

Anyway, fingers crossed you guys find the cause of the issue, the releases it's holding up are not critical, yet...

Hi all, I spun up a VSTS hosted image and created a small project and it worked fine.
I've attached the relevant part of the log below.
As I mentioned before, the most helpful thing for me would be to have "diagnostic" logs.
This can be done by adding /v:diag
to the "MSBuild Arguments" field of your build task.
This will explicitly show the file path of the dll being loaded, the file path of the targets file, and all of the arguments that are being passed to the MSBuild task that's failing.

build.log

Hi @uniqueiniquity , will this do:

2018-03-22T17:37:57.9493213Z Using "VsTsc" task from assembly "C:\Users\VssAdministrator\.nuget\packages\microsoft.typescript.msbuild\2.6.2\build\\..\tools\net45\TypeScript.Tasks.dll".
2018-03-22T17:37:57.9496434Z Task "VsTsc" (TaskId:2738)
2018-03-22T17:37:57.9496807Z   Task Parameter:ToolPath=C:\Users\VssAdministrator\.nuget\packages\microsoft.typescript.msbuild\2.6.2\build\\..\tools\tsc (TaskId:2738)
2018-03-22T17:37:57.9497338Z   Task Parameter:IsFileSystemCaseSensitive=False (TaskId:2738)
2018-03-22T17:37:57.9497662Z   Task Parameter:TSConfigFile=Scripts\tsconfig.json (TaskId:2738)
2018-03-22T17:37:57.9497968Z   Task Parameter:YieldDuringToolExecution=True (TaskId:2738)
2018-03-22T17:37:57.9498521Z   Task Parameter:ProjectDir=D:\a\1\s\RailDashboard\ (TaskId:2738)
2018-03-22T17:37:57.9498859Z   Task Parameter:TypeScriptCompileBlocked=False (TaskId:2738)
2018-03-22T17:37:57.9504067Z ##[error]C:\Users\VssAdministrator\.nuget\packages\microsoft.typescript.msbuild\2.6.2\tools\Microsoft.TypeScript.targets(208,7): Error MSB4064: The "ComputeOutputOnly" parameter is not supported by the "VsTsc" task. Verify the parameter exists on the task, and it is a settable public instance property.
2018-03-22T17:37:57.9505767Z C:\Users\VssAdministrator\.nuget\packages\microsoft.typescript.msbuild\2.6.2\tools\Microsoft.TypeScript.targets(208,7): error MSB4064: The "ComputeOutputOnly" parameter is not supported by the "VsTsc" task. Verify the parameter exists on the task, and it is a settable public instance property. [D:\a\1\s\Dashboard\Dashboard.csproj]
2018-03-22T17:37:57.9524416Z ##[error]C:\Users\VssAdministrator\.nuget\packages\microsoft.typescript.msbuild\2.6.2\tools\Microsoft.TypeScript.targets(197,5): Error MSB4063: The "VsTsc" task could not be initialized with its input parameters. 
2018-03-22T17:37:57.9526596Z C:\Users\VssAdministrator\.nuget\packages\microsoft.typescript.msbuild\2.6.2\tools\Microsoft.TypeScript.targets(197,5): error MSB4063: The "VsTsc" task could not be initialized with its input parameters.  [D:\a\1\s\Dashboard\Dashboard.csproj]
2018-03-22T17:37:57.9527093Z Done executing task "VsTsc" -- FAILED. (TaskId:2738)

The project is .net 4.6.2 should that be relevant. I've got to go out for a while so I might not be able to reply again until tomorrow.

Many Thanks,

Roger

@RogerDawson, that actually did help a lot, thank you.
Here's what's happening; the TypeScript.Tasks.dll that ships with VS 15.6 is a newer version than what ships with the NuGet package.
For some reason, the in-box dll is being loaded first, so the dll from the NuGet package is not loaded.
We have updated the NuGet package to 2.6.5 so that it matches the in-box dll, so the scenario in which you have upgraded your project to 2.6 should work.

However, to focus on @spelltwister's scenario, it is still possible to load the in-box dll and try to use the 2.3 targets file. We are working on changes that will fix this issue in general, but in the short term, if you are not able to upgrade to 2.6, you will need to ensure that no other part of your build is pulling in the in-box TypeScript dll. To do so, you should ensure you're either including the TypeScript NuGet package on every project being built, or at least ensuring that all projects that don't have TypeScript don't mention TypeScript in their .csproj files (and ensuring all that do are using the NuGet package).

Please let me know if this helps, and thank you for your help in figuring this out!

Hello @uniqueiniquity ,

I ran the build in VSTS again after I had upgraded the nuget package to 2.6.5 and it worked successfully. Thanks for fixing this.

Two more questions if I may though - firstly regarding what will happen if the version of Visual Studio that ships with VSTS were to be upgraded again (as I'm assuming that is what has caused this issue). Would we experience the same problems again or is it the intention to fix the problem of the wrong dll being loaded as the long-term solution?

Finally, does anyone know if there is an accurate list of what is actually shipping with the VSTS Hosted 2017 build agent? This page here Hosted agents for VSTS has an inventory link that takes you to a readme in github but that suggests it ships with 2.0, 2.1 and 2.2 which I'm guessing is incorrect. The readme looks like it is actively being worked on so it should be current.

Many Thanks

Roger

Here's my analysis of this problem:

When does this error come up?

Once scenario (which is hitting us hard) where this error comes up when the highest effective TypeScriptToolsVersion >= 2.6 and the lowest is <= 2.5 across all TypeScript enabled projects in the currently loaded solution. We have this because we are incrementally upgrading projects from 2.4 to 2.7 and can't do this big bang primarily because noUsedLocals has become stricter and requires code changes to make it comply with the stricter model.

Why does this error come up?

In version 2.6, the ComputeOutputOnly property for the VsTsc task (the task that's defined in Microsoft.TypeScript.Tasks.dll and is responsible for invoking the actual TypeScript compiler) was renamed to ComputeInputAndOutputOnly. Although Visual Studio has all the plumbing in place to try and load Microsoft.TypeScript.Tasks.dll from the right folder, if/once the 2.7 DLL gets loaded, attempts to load the 2.4 DLL result in that same DLL being used which doesn't have the ComputeOutputOnly property. This is in turn because their TypeNames, including their AssemblyVersion, are same but their public signature (and code) is obviously different. It seems the actual DLL loaded (first) is based on the highest TypeScriptEffectiveToolsVersion rather than which project is compiled first which is why the error is always about the missing old property rather than the missing new property.

Workaround we've implemented

  1. Close all instances of VS2017.
  2. Go to the C:\Program Files (x86)\Microsoft SDKsTypeScript\2.7\build folder using Windows Explorer.
  3. Rename the TypeScript.Tasks.dll to TypeScript.Tasks.dll.27 and Microsoft.TypeScript.targets to Microsoft.TypeScript.targets.27.
  4. Change 2.7 in the address bar to 2.4 to get to the equivalent folder for 2.4.
  5. Copy TypeScript.Tasks.dll and Microsoft.TypeScript.targets from there, press back and paste them in the 2.7 folder. Note that these are only the "Tasks" DLL and the targets file but not the actual compiler. The DLL must match the targets file.

Closing remarks

This is a general .NET limitation that two assemblies with the same TypeName can't be loaded in the same process (AppDomain+LoadContext to be more specific) so this is a fundamental flaw/shortcoming in the concurrent-multi-version support for TypeScript. The official fix would probably have to be at least assign these Tasks assemblies a different AssemblyVersion for each TypeScript release. Once again, our workaround downgrades only the VsTsc task but the actual compiler (tsc.exe) will still be picked based on the TypeScriptToolsVersion in the project allowing us to upgrade each project on its own schedule.

@RogerDawson the intention is definitely to fix the problem of the wrong dll being loaded as the long-term solution, and we're looking at a couple different approaches for doing that. At this point (as of Visual Studio version 15.7 Preview 2) VS 15.7 will ship with TS 2.8, so if it happens again, that would be the NuGet package to use for this workaround.

To answer your second question, I think that page is in fact accurate. The thing that is not explicitly stated on that page, though, is that VS itself ships with a version of TypeScript (i.e. the page seems to only list the optional components). In VS 15.6, we include TS 2.6.

@Manish3177 Thank you for your detailed response and suggested workaround! As I mentioned above, we are actively working to resolve this issue, and I apologize for the difficulties this has caused.

For those who are seeing error MSB4062: The "TypeScript.Tasks.GenerateOutputLogs" task could not be loaded from the assembly C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.6\build\TypeScript.Tasks.dll. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. in situations like @Manish3177 described, a short term workaround seems to be forcing projects with earlier versions of TS to compile first via adding project references.

Had the same issue with Azure generated app.

Not sure if this will spark any ideas.
I created the basic ToDo app on Azure and unzipped the download project.
I then created a basic cordova app using VS2017 community 15.6.4
The VS app compiles without issue.
Below is an image of the two auto created projects.
capture

I’m also facing the same problem, please try to resolve it fast.

I had the same issue here. I just deleted the entire folder "2.3" from "C:\Program Files (x86)\Microsoft SDKsTypeScript"
It works nicely now...

Any more updates on this?

Upgrading to Microsoft.TypeScript.MSBuild 2.8.3 fixed this issue for me. Using VS 2017 15.5.7.

I've got an app that relies on Microsoft.TypeScript.MSBuild 1.8.11 and get this error using Visual Studio 15.6.4. Upgrading the package is problematic because several dependency typescript libraries break with TS >= 2.4. I shouldn't have to upgrade to a new version of typescript, and thus upgrade several typescript libraries, and potentially update my code that uses those dependencies, then test everything, just to be able to use a new dot-release of visual studio. I've very unhappy with this bug.

Sorry for the lack of updates on the issue. It's been fixed in TypeScript 2.8.

The 2.8 SDK is available in Visual Studio 15.7, which is currently in preview. For most people, upgrading to Visual Studio to 15.7, installing the TypeScript 2.8 SDK directly, or installing the TypeScript 2.8 Nuget package will solve the issue.

If you're still seeing this bug, ensure at least _one_ of the following is true for your solution:

  • All TypeScript projects in the solution have the <TypeScriptToolsVersion> property set, and it's the same version for all of them.
  • All TypeScript projects are targeting the same version of the TypeScript Nuget package, and you have the corresponding TypeScript SDK version installed (download link that contains all versions)
  • If you have two projects in the same solution that are targeting different versions of TypeScript, at least one of them targets 2.8 or higher. For example, if you have one project that uses <TypeScriptToolsVersion>2.3</TypeScriptToolsVersion> and you just can't change that, just make sure that all the other projects are either set to 2.3, or 2.8.

If that still isn't working, please let me know which errors you're seeing and which version(s) of TypeScript you're using in your projects. Thanks!

This is not 'fixed' by any stretch of the imagination. VS2017 still has the same problems, all above solutions not withstanding.

Please stop closing this issue until you've actually _fixed_ the issue.

@cgraamans sorry to hear it hasn't been fixed for you. Could you let me know the exact error you're seeing and which version(s) of TypeScript and VS you are using? Thanks!

Hi, I am using VS 2017 and Microsoft.TypeScript.MSBuild v2.8.1 and still get this error intermittently when I build.
Error MSB4062 The "TypeScript.Tasks.GenerateOutputLogs" task could not be loaded from the assembly
.nuget\packages\microsoft.typescript.msbuild\2.8.1\build\..\tools\net45TypeScript.Tasks.dll. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
So far the only semi-reliable work around I have (without closing VS after every failed build) is to Clean and Build the Web solution again (Rebuild does not work), but this issue is still not resolved.

@beirnem sorry you're still seeing it. Could you go through this comment and see if your solution meets any of the requirements? https://github.com/Microsoft/TypeScript/issues/22422#issuecomment-385003820

If you're willing to share, a detailed (msbuild /flp:verbosity=detailed) msbuild log would be very helpful for me to diagnose. Or even just the lines from the log containing "TypeScript".

I have VS version 2017.15.6.2

For solutions, install or update lasted nugget package from current project:

TypeScript.MSBuildTask
Microsoft.TypeScript.Compiler
Microsoft.TypeScript.MSBuild

That was really helpfull

For anyone still getting this in 2020 with Visual Studio 2019. You need to restore your nuget packages, but first, you need to clear your global repository:
Close Visual Studio then:
dotnet nuget locals global-packages --clear

Then delete/rename your packages folder inside your project folder.
Restart Visual Studio and do a NuGet Restore from VS as normal.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

siddjain picture siddjain  ·  3Comments

weswigham picture weswigham  ·  3Comments

fwanicka picture fwanicka  ·  3Comments

MartynasZilinskas picture MartynasZilinskas  ·  3Comments

blendsdk picture blendsdk  ·  3Comments