最近在家中使用個人筆電嘗試 Visual Studio 將 Docker Image 部署至 Azure 的流程,在嘗試過程中進行 publish 部署時一直發生錯誤造成部署失敗無法繼續,錯誤訊息為 'Publish has encountered an error. Build Failed. Check the Output windows for more details. A diagonstic log has been written to the following location: C:\Users\UserName\AppData\Local\Temp\xxxx.tmp' ,這篇文章就針對此問題的解決方式做分享,若是有不清楚或是錯誤的地方歡迎討論予糾正。
案發現場
異常發生時畫面如下
錯誤訊息中提到在 C:\Users\UserName\AppData\Local\Temp 資料夾底下有記錄錯誤 log,Log 內容如下
System.AggregateException: One or more errors occurred. ---> System.Exception: Build failed. Check the Output window for more details. --- 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 Microsoft.WebTools.Publish.PublishService.VsWebProjectPublish.<>c__DisplayClass43_0.<PublishAsync>b__3() at System.Threading.Tasks.Task`1.InnerInvoke() at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Publish.Framework.ViewModel.ProfileSelectorViewModel.<RunPublishTaskAsync>d__176.MoveNext() ---> (Inner Exception #0) System.Exception: Build failed. Check the Output window for more details.<--- ===================從錯誤訊息中看不出可能異常的原因,只有在最後一行提到想了解更多錯誤的細節。參考 MSDN 論壇 publish has encountered an error Object reference not set to an instance of an object A diagnostic log has been written to following location 建議解法進行嘗試,試過權限的檢查、Docker for windows 更新至最新版都無效,開啟 Visual Studio Installer 也有安裝 Azure development ,但有安裝要如何確認安裝的元件是沒有遺漏的,因此這邊我再透過 powershell 指令檢查關鍵字 Azure 相關的元件
Get-Module -ListAvailable | Where-Object -Property Name -Like "*Azure*"在將個人電腦查出來的結果在與公司電腦進行比對,經過比對之後發現竟然少了1/3 的內容,猜測可能這就是造成 docker 部署至 Azure 異常的原因,下一步就是使用 Visual Studio Installer 移除 Azure development,在進行重新安裝的動作
安裝需要重新下載 Azure Development 安裝檔約 700M 左右
安裝完畢之後,再重新進行將應用程式 publish 到 Azure 的動作即可正常運行,宣告除蟲大成功 !!!
8/5 更新 : 在 MSDN 有提供 Visual Studio 2019 安裝元件 (workload) 的目錄與清單,因此如果有異常的朋友可以與官網提供的 Azure Development 安裝清單比對即可,傳送門
publish has encountered an error Object reference not set to an instance of an object A diagnostic log has been written to following location
0 意見:
張貼留言