最近因VS2022從V16升級(jí)到版本 17.4.0后,項(xiàng)目忽然編譯錯(cuò)誤,后經(jīng)反復(fù)排錯(cuò)發(fā)現(xiàn):項(xiàng)目路徑減短項(xiàng)目就不會(huì)出錯(cuò)。出錯(cuò)內(nèi)容如下:
嚴(yán)重性?? ?代碼?? ?說(shuō)明?? ?項(xiàng)目?? ?文件?? ?行?? ?禁止顯示狀態(tài)
錯(cuò)誤?? ?MSB4018?? ?“GenerateStaticWebAsssetsPropsFile”任務(wù)意外失敗。
System.IO.DirectoryNotFoundException: 未能找到路徑“E:\個(gè)人總結(jié)目錄\源碼樣例\C#\后平臺(tái)開(kāi)源框架\…….WebApiSite.Platform\obj\Debug\net6.0\staticwebassets\msbuild.…….Presentation.WebApiSite.Platform.Microsoft.AspNetCore.StaticWebAssets.props”的一部分。
? ?在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
? ?在 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)
? ?在 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
? ?在 System.IO.File.InternalWriteAllBytes(String path, Byte[] bytes, Boolean checkHost)
? ?在 Microsoft.AspNetCore.Razor.Tasks.GenerateStaticWebAsssetsPropsFile.ExecuteCore()
? ?在 Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
? ?在 Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()?? ?Admin.NET.Presentation.WebApiSite.Platform?? ?C:\Program Files\dotnet\sdk\7.0.100\Sdks\Microsoft.NET.Sdk.Razor\targets\Microsoft.NET.Sdk.Razor.StaticWebAssets.Pack.targets?? ?141?? ?文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-609858.html
以上錯(cuò)誤原因是:因項(xiàng)目路徑放得太深,導(dǎo)致VS編譯程序支持的路徑超長(zhǎng),導(dǎo)致編譯時(shí)提示***路徑無(wú)法找到。解決方案很簡(jiǎn)單,減少項(xiàng)目深度,將其提到盤(pán)符根目錄,再次運(yùn)行則不再出錯(cuò)。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-609858.html
到了這里,關(guān)于Visual Studio 編譯項(xiàng)目出錯(cuò):錯(cuò)誤 MSB4018 “GenerateStaticWebAsssetsPropsFile”任務(wù)意外失敗的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!