【问题标题】:The "CheckFileSystemCaseSensitive" task failed unexpectedly, Could not load file or assembly 'System.IO.FileSystem“CheckFileSystemCaseSensitive”任务意外失败,无法加载文件或程序集“System.IO.FileSystem”
【发布时间】:2017-10-03 04:02:23
【问题描述】:

在我的 Visual Studio 2017、ASP.NET Core、MVC Web 项目中,我刚刚添加了 Microsoft.TypeScript.MSBuild NuGet 包 v2.3.1,同时将我的 ASP.NET Core 程序集从 1.0.* 更新到了 1.1.1。现在,当我构建项目时突然出现以下异常:

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()

双击异常消息会在 Microsoft.TypeScript.targets 文件中的这些行中找到一个:

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

它说“未定义 MSBuildThisFileFullPath”。

我已尝试添加对 NETStandard.Library 的引用,如下所示:https://github.com/dotnet/corefx/issues/16206,但这没有任何区别。

诊断 MSBuild 输出如下所示:

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.

感谢您的任何建议。

【问题讨论】:

  • 我注意到,System.IO.FileSystem 的最新版本是 4.3.0,而不是 4.0.1.0。
  • MSBuild 分发自己的外观程序集副本,允许根据 netstandard 构建的任务运行。我建议将此作为错误提交到 github.com/Microsoft/msbuild/issues
  • 更多信息:如果我删除项目根目录中的“obj”文件夹,则构建成功,直到我关闭并重新启动 Visual Studio。重新启动 Visual Studio 后重建,然后再次遇到错误。我可以删除 obj 文件夹,错误再次消失。重建解决方案没有任何区别,关闭和重新打开项目或解决方案也没有区别。
  • 到目前为止,这在我看来像是打字稿任务或 msbuild 中的错误。但我认为我可以建立一个解决方法(通过替换失败的目标)。您的目标是 netcoreapp1.1 还是 .net 框架 TFM?

标签: typescript msbuild visual-studio-2017 asp.net-core-1.1


【解决方案1】:

我在 Vs2015 中遇到了同样的错误,我从 https://www.microsoft.com/en-us/download/confirmation.aspx?id=48593 安装了类型脚本, 错误消失了,你可以试试

【讨论】:

【解决方案2】:

(老问题,但这可能会帮助其他人寻找解决此问题的方法):

作为为您的 VS 项目配置 TypeScript 的另一种方法,您可以尝试将 Microsoft TypeScript Compiler nuget 包添加到解决方案中,而不是 Microsoft.TypeScript.MSBuild 包。您可能需要在 .csproj 文件中配置&lt;TypeScriptToolsVersion&gt;(例如,您只需要次要和主要版本):

<TypeScriptToolsVersion>2.3</TypeScriptToolsVersion>

【讨论】:

    【解决方案3】:

    对于 Visual Studio 2017,直接从 TypeScript SDK 下载页面安装 TypeScript 3.0 SDK。download

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-19
      • 1970-01-01
      • 2011-04-15
      • 1970-01-01
      • 2017-12-01
      相关资源
      最近更新 更多