生成静态Web资源属性文件任务意外失败。

6
我有一个包含大约40个项目的.NET 6解决方案。
在构建解决方案时,我遇到了以下错误。
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()

有趣的是,这个错误被报告在以下文件中:C:\Program Files\dotnet\sdk\7.0.100\Sdks\Microsoft.NET.Sdk.Razor\targets\Microsoft.NET.Sdk.Razor.StaticWebAssets.Pack.targets
我注意到路径中显示了7.0.100,但我的所有项目都是针对.NET 6的。
我不知道这是否是原因,我2天前更新了VisualStudio,并下载了.NET 7,但我没有更改项目的目标,所以我有点困惑为什么使用.NET 7,或者这是否与我无法构建解决方案的问题有关。
1个回答

30

文件路径过长
将项目名称缩短,或移动到文件夹名较短的位置。
这个问题实际上是在更新 Visual Studio 后出现的。


1
是的,我将项目复制到了一个比当前路径更短的路径中,问题已经解决。谢谢。 - Hakan Fıstık
我已经升级到Visual Studio 17.7.0预览版1.0,但问题仍然存在,这个问题会被修复吗? - Stavros Koureas
很奇怪,但是我已经将父文件夹source\repos重新定位到C:\下,并将位置更改为VisualStudio->Tools。 - Stavros Koureas
这对我有用。将项目移动到更短的路径,一切都很好。干杯 - undefined
2
给这个人一杯啤酒!谢谢! - undefined
显示剩余2条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接