Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The GenerateStaticWebAsssetsPropsFile task failed unexpectedly

I have .NET 6 solution, with about 40 projects.
When building the solution I am getting the following error

The "GenerateStaticWebAsssetsPropsFile" task failed unexpectedly.
System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\..\SolutionName\ProjectName\obj\Debug\net6.0\staticwebassets\msbuild.MyProjectName.Microsoft.AspNetCore.StaticWebAssets.props'.
   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, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.File.InternalWriteAllBytes(String path, Byte[] bytes, Boolean checkHost)
   at Microsoft.AspNetCore.Razor.Tasks.GenerateStaticWebAsssetsPropsFile.ExecuteCore()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

The interesting thing is that this error is reported to be in the
C:\Program Files\dotnet\sdk\7.0.100\Sdks\Microsoft.NET.Sdk.Razor\targets\Microsoft.NET.Sdk.Razor.StaticWebAssets.Pack.targets file

I notice that the path reporting 7.0.100 but all of my projects are targeting .NET 6.

I do not know if this is the reason or not, I updated VisualStudio 2 days ago, and I downloaded .NET 7, but I did not change the Target of the project, so I am a little bit confused why .NET 7 is used. or if any of this is related to the problem I am having that is preventing me from building the solution

like image 563
Hakan Fıstık Avatar asked Jan 19 '26 18:01

Hakan Fıstık


1 Answers

Too long filepath.
Make the project name shorter, or move it to a folder with shorter names.
This problem actually appeared with the Visual Studio update

More context: The project name part the original answer referred to is very important: The build process that builds this 'Props file' uses your project name to generate a very long ms.build.Your.Long.Project.Name.Here.file inside the bin/*/ build folder.

So, using a shorter project name should allow this 'Props file' to be generated successfully.

like image 109
Eugeny Myakishev Avatar answered Jan 22 '26 08:01

Eugeny Myakishev