.net - "GetFileHash"任务意外失败

标签 .net visual-studio asp.net-core blazor blazor-webassembly

我正在开发 Blazor Web Assembly 项目,但在构建时遇到错误,如下所示:

Severity    Code    Description Project File    Line    Suppression State
Error   MSB4018 The "GetFileHash" task failed unexpectedly.
System.AggregateException: One or more errors occurred. ---> System.IO.IOException: The process cannot access the file 'D:\New folder\projects\Al-Tanzil.org\Source\TechFlurry.AlTanzil\TechFlurry.AlTanzil.App\wwwroot\debug.log' because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Microsoft.Build.Tasks.GetFileHash.ComputeHash(Func`1 algorithmFactory, String filePath)
   at Microsoft.Build.Tasks.GetFileHash.<>c__DisplayClass28_0.<Execute>b__0(Int32 index)
   at System.Threading.Tasks.Parallel.<>c__DisplayClass17_0`1.<ForWorker>b__1()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
   at System.Threading.Tasks.Task.<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(Object <p0>)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
   at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, Action`1 body)
   at Microsoft.Build.Tasks.GetFileHash.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
---> (Inner Exception #0) System.IO.IOException: The process cannot access the file 'D:\New folder\projects\Al-Tanzil.org\Source\TechFlurry.AlTanzil\TechFlurry.AlTanzil.App\wwwroot\debug.log' because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Microsoft.Build.Tasks.GetFileHash.ComputeHash(Func`1 algorithmFactory, String filePath)
   at Microsoft.Build.Tasks.GetFileHash.<>c__DisplayClass28_0.<Execute>b__0(Int32 index)
   at System.Threading.Tasks.Parallel.<>c__DisplayClass17_0`1.<ForWorker>b__1()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
   at System.Threading.Tasks.Task.<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(Object <p0>)<---
    TechFlurry.AlTanzil.App C:\Users\nobel\.nuget\packages\microsoft.aspnetcore.components.webassembly.build\3.2.1\targets\ServiceWorkerAssetsManifest.targets  134 


The service worker assets manifest file:

    <GetFileHash Files="@(_StaticWebAssetsWithoutHash)" Algorithm="SHA256" HashEncoding="base64">
          <Output TaskParameter="Items" ItemName="_StaticWebAssetHash" />
    </GetFileHash>

有人可以帮我解决这个问题吗?我迫切需要一个解决方案,在互联网上搜索但没有找到。

最佳答案

您打开了文件 debug.log(可能是在记事本中),您需要关闭它以便可以写入日志。

关于.net - "GetFileHash"任务意外失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64735829/

相关文章:

c# - 当 WPF 窗口发生变化时如何得到通知?

c# - 使用 Linq 从数组构建字典

html - Visual Studio 中 angular 在 html 中的静态类型

typescript - 解决 "Cannot invoke an expression whose type lacks a call signature"typescript 错误 - Visual Studio C# React/Redux 模板

c# - 有没有 asp.net fiddle ?

c# - 在 Visual Studio 2015 中滚动智能感知列表的键绑定(bind)是什么?

sql-server - 数据库选项具有对文件组 [FILESTREAM] 的未解析引用

c# - .NET Core 使用配置绑定(bind)到带有数组的选项

asp.net-core - itext7将html转换为pdf(asp.net core 2.1)得到错误 "Cannot access a closed stream"

c# - WriteableBitmap访问冲突问题