"GetFileHash" 任务意外失败

The "GetFileHash" task failed unexpectedly

我正在处理 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.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,可能是在记事本中,您需要关闭它以便写入日志。