Typescript: The "CheckFileSystemCaseSensitive" task failed unexpectedly, Could not load file or assembly 'System.IO.FileSystem

Created on 8 May 2017  路  14Comments  路  Source: microsoft/TypeScript

_From @dkent600 on May 4, 2017 21:48_

To my Visual Studio 2017, ASP.NET Core, MVC web project I just added the Microsoft.TypeScript.MSBuild NuGet package v2.3.1, and simultaneously updated my ASP.NET Core assemblies from 1.0.* to 1.1.1. Now suddenly when I build my project I get the following exception:

Severity    Code    Description Project File    Line    Suppression State
Error   MSB4018 The "CheckFileSystemCaseSensitive" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'System.IO.FileSystem, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.IO.FileSystem, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at TypeScript.Tasks.CheckFileSystemCaseSensitive.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

Double-clicking on the exception message takes one to these lines in the file Microsoft.TypeScript.targets:

<Target Name="CheckFileSystemCaseSensitive">
    <CheckFileSystemCaseSensitive
       MSBuildThisFileFullPath="$(MSBuildThisFileFullPath)" >
      <Output TaskParameter="IsFileSystemCaseSensitive"  PropertyName="IsFileSystemCaseSensitive" />
    </CheckFileSystemCaseSensitive>
</Target>

where it says that "MSBuildThisFileFullPath is not defined".

I've tried adding references to NETStandard.Library, as suggested here: https://github.com/dotnet/corefx/issues/16206, but that doesn't make any difference.

The diagnostic MSBuild output looks like this:

1>Target "CheckFileSystemCaseSensitive" in file "C:\Users\dkent\.nuget\packages\microsoft.typescript.msbuild\2.3.1\tools\netstandard1.3\Microsoft.TypeScript.targets":
1>  Using "CheckFileSystemCaseSensitive" task from assembly "C:\Users\dkent\.nuget\packages\microsoft.typescript.msbuild\2.3.1\tools\netstandard1.3\TypeScript.Tasks.dll".
1>  Task "CheckFileSystemCaseSensitive"
1>    Task Parameter:MSBuildThisFileFullPath=C:\Users\dkent\.nuget\packages\microsoft.typescript.msbuild\2.3.1\tools\netstandard1.3\Microsoft.TypeScript.targets
1>    [...]\.nuget\packages\microsoft.typescript.msbuild\2.3.1\tools\netstandard1.3\Microsoft.TypeScript.targets(172,5): error MSB4018: The "CheckFileSystemCaseSensitive" task failed unexpectedly.
1>    [...]\.nuget\packages\microsoft.typescript.msbuild\2.3.1\tools\netstandard1.3\Microsoft.TypeScript.targets(172,5): error MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'System.IO.FileSystem, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
1>    [...]\.nuget\packages\microsoft.typescript.msbuild\2.3.1\tools\netstandard1.3\Microsoft.TypeScript.targets(172,5): error MSB4018: File name: 'System.IO.FileSystem, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
1>    [...]\.nuget\packages\microsoft.typescript.msbuild\2.3.1\tools\netstandard1.3\Microsoft.TypeScript.targets(172,5): error MSB4018:    at TypeScript.Tasks.CheckFileSystemCaseSensitive.Execute()
1>    [...]\.nuget\packages\microsoft.typescript.msbuild\2.3.1\tools\netstandard1.3\Microsoft.TypeScript.targets(172,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>    [...]\.nuget\packages\microsoft.typescript.msbuild\2.3.1\tools\netstandard1.3\Microsoft.TypeScript.targets(172,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
1>  Done executing task "CheckFileSystemCaseSensitive" -- FAILED.

_Copied from original issue: Microsoft/msbuild#2061_

Bug Fixed

Most helpful comment

I am still facing this issue with 'Microsoft.TypeScript.MSBuild 2.4.1'. The build/compiler works fine in my local machine. In my build server (which uses vs-2013 build agent), it fails with the following message

F:\Blds...\DEV\packages\Microsoft.TypeScript.MSBuild.2.4.1\tools\Microsoft.TypeScript.targets(174,5): error MSB4062: The "TypeScript.Tasks.CheckFileSystemCaseSensitive" task could not be loaded from the assembly F:\Blds...\DEV\packages\Microsoft.TypeScript.MSBuild.2.4.1\build\..\tools\net45\TypeScript.Tasks.dll. Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. 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.

All 14 comments

_From @dkent600 on May 4, 2017 21:50_

I note, for what it's worth, that the latest version of System.IO.FileSystem is 4.3.0, not 4.0.1.0. But installing 4.0.1.0 to my project makes no difference.

_From @dkent600 on May 4, 2017 22:48_

Is there at least a work-around for this?

_From @dkent600 on May 6, 2017 21:47_

More info:

If I delete the "obj" folder in the root of the project, then the build succeeds until I close and restart Visual Studio. Rebuilding after restarting Visual Studio then again hits the error. I can delete the obj folder and again the error disappears.

Rebuild Solution makes no difference, nor does Clean Solution or closing and reopening either the project or the solution.

_From @AnsonWooBizCloud on May 7, 2017 4:21_

I hit this error too, and your workaround works for me (delete the obj folder), thank you!
I hope Microsoft will fixed it soon, quite annoying

This is a bug in the CheckFileSystemCaseSensitive task, which is distributed by TypeScript. Because it doesn't ship its dependency System.IO.FileSystem.dll, it only works if another task has loaded System.IO.FileSystem earlier in the build. On an incremental build, that's not happening (I suspect that the compiler task is what loads it when it works).

One possible workaround would be to define a property to disable incremental builds in your project. This will cause build times to increase (because the compiler will run all the time), but will force the compiler to run. If I'm right that the compiler is what's forcing the load, this should work around the problem.

You can try that by setting the property

<NonExistentFile>WorkaroundForTypescriptBuildTask</NonExistentFile>

in your project file.

This class of bug could be alleviated by Microsoft/msbuild#1542.

@rainersigwald Thanks for providing workaround for the customers. Question - shouldn't "netstandard1.3" ship with "System.IO.FileSystem.dll" and " System.IO.FileSystem.Primitives.dll"? from our long ago discussion, Typescript should only need to ship these dependency for "net45"

@yuit This problem is arising in Visual Studio, which is using full-framework MSBuild and should use the net45 version of the TypeScript tasks.

@rainersigwald gotcha! The PR to fix this is in our internal repo

Update for others: the fix is in the PR. we will check it in tomorrow if nothing goes wrong and the our NuGet nightly should contain this fix

The fix should be in NuGet nightly today

I am still facing this issue with 'Microsoft.TypeScript.MSBuild 2.4.1'. The build/compiler works fine in my local machine. In my build server (which uses vs-2013 build agent), it fails with the following message

F:\Blds...\DEV\packages\Microsoft.TypeScript.MSBuild.2.4.1\tools\Microsoft.TypeScript.targets(174,5): error MSB4062: The "TypeScript.Tasks.CheckFileSystemCaseSensitive" task could not be loaded from the assembly F:\Blds...\DEV\packages\Microsoft.TypeScript.MSBuild.2.4.1\build\..\tools\net45\TypeScript.Tasks.dll. Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. 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.

The problem came back for me today (TS 2.4.1, VS 2017.3) with command-line MSBuild 15 failing. The resolution was to kill hanging MSBuild processes between my build steps (suspecting file in use although the error message said nothing about that).

I confirm @rohatsu the problem is still present in vs 15.3.2 馃槩

Issue is gone for me after updating to newest VS 15.5.6

Was this page helpful?
0 / 5 - 0 ratings

Related issues

manekinekko picture manekinekko  路  3Comments

kyasbal-1994 picture kyasbal-1994  路  3Comments

uber5001 picture uber5001  路  3Comments

siddjain picture siddjain  路  3Comments

weswigham picture weswigham  路  3Comments