Open
Description
Describe the bug
After upgrading Visual Studio to version 17.14.0, I started encountering this issue.
To resolve it, I first performed a Repair using the Visual Studio Installer, but the problem persisted.
For further troubleshooting, I completely uninstalled Visual Studio and installed only the .NET SDK manually.
Then, I installed the required workloads using the CLI. However, even after creating a clean Blazor WebAssembly project and building it, the same error still occurred.
However, I was able to temporarily work around the problem by manually installing .NET SDK 9.0.204 after reinstalling Visual Studio, and then deleting the folder C:\Program Files\dotnet\sdk\9.0.300
.
This resolved the build error both in Visual Studio and when using the CLI.
To Reproduce
- Install .Net SDK 9.0.300
- Install Workload
dotnet workload install wasm-tools
- Create New Project
dotnet new blazorwasm -o _MyCleanApp --framework net9.0
- Just Build
Exceptions
Restore complete (0.5s)
_MyCleanApp failed with 1 error(s) (0.3s)
C:\Program Files\dotnet\sdk\9.0.300\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets(125,5): error MSB4018:
The "DefineStaticWebAssetEndpoints" task failed unexpectedly.
System.AggregateException: One or more errors occurred. (Last write time for 'D:\_MyCleanApp\bin\Debug\net9.0\wwwroot\_framework\blazor.webassembly.js' is not defined.)
---> System.InvalidOperationException: Last write time for 'D:\_MyCleanApp\bin\Debug\net9.0\wwwroot\_framework\blazor.webassembly.js' is not defined.
at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.Validate()
at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.FromTaskItem(ITaskItem item)
at Microsoft.AspNetCore.StaticWebAssets.Tasks.DefineStaticWebAssetEndpoints.ParallelWorker.Process(Int32 i, ParallelLoopState _)
at Microsoft.AspNetCore.StaticWebAssets.Tasks.DefineStaticWebAssetEndpoints.<>c.<Execute>b__16_2(Int32 i, ParallelLoopState loop, ParallelWorker state)
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica.Execute()
--- End of inner exception stack trace ---
at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
at System.Threading.Tasks.Parallel.ForWorker[TLocal,TInt](TInt fromInclusive, TInt toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.ForWorker[TLocal,TInt](TInt fromInclusive, TInt toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
at System.Threading.Tasks.Parallel.For[TLocal](Int32 fromInclusive, Int32 toExclusive, Func`1 localInit, Func`4 body, Action`1 localFinally)
at Microsoft.AspNetCore.StaticWebAssets.Tasks.DefineStaticWebAssetEndpoints.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(TaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
Build failed with 1 error(s) in 1.0s
Further technical details
.NET SDK:
Version: 9.0.300
Commit: 15606fe0a8
Workload version: 9.0.300-manifests.87b8cca8
MSBuild version: 17.14.5+edd3bbf37
Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.300\
.NET workloads installed:
[wasm-tools]
Installation Source: VS 17.14.36109.1
Manifest Version: 9.0.5/9.0.100
Manifest Path: c:\program files\dotnet\sdk-manifests\9.0.100\microsoft.net.workload.mono.toolchain.current\9.0.5\WorkloadManifest.json
Install Type: Msi
Configured to use loose manifests when installing new manifests.
Host:
Version: 9.0.5
Architecture: x64
Commit: e36e4d1a8f
.NET SDKs installed:
9.0.204 [C:\Program Files\dotnet\sdk]
9.0.300 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found