webdeploy環境搭建

. 服務器配置

  •  爲了使用web deploy進行發佈,你首先要安裝web deploy工具,
  •  可以從WebPlatform Installer中選擇最新的版本進行安裝,需要注意的是,安裝web deploy時最好全部安裝,不然會出現一些奇奇怪怪的問題
  •  如果你還沒有webPlatform Installer,你可以去MSDN https://www.microsoft.com/web/downloads/platform.aspx 下載
  •  安裝號web delopy後點擊你的IIS服務器,https://img2018.cnblogs.com/blog/1168541/201907/1168541-20190714154803255-67793477.png,你應該能看到

https://img2018.cnblogs.com/blog/1168541/201907/1168541-20190714154911483-2021832510.png

 

  •   其中的管理服務,如果沒有看到,請嘗試重新安裝web deploy工具
  •  雙擊管理服務器,
  • https://img2018.cnblogs.com/blog/1168541/201907/1168541-20190714155031335-604412845.png

 

  •  請留意這裏的端口號,以及IP地址限制這兩欄,
    • 若你未使用默認端口,在配置Visual studio中的發佈配置文件時就需要爲你的服務器指定端口,
    • 若這裏的IP地址限制中,未指定的客戶端的訪問全爲禁止,那麼你需要指定你的發佈客戶端所在IP被允許訪問
    • 若以上兩點未做到,在發佈時會出現 could not connect to the remote computer('IP') using the specified process (" Web Management Service ") xxx
  •  有了以上步驟後,你的Visual studio在發佈時就能 成功 connect了,但是依然可能發佈失敗
  •  IIS中,選中你將要發佈的網站 
  • https://img2018.cnblogs.com/blog/1168541/201907/1168541-20190714155743455-1732149348.png

 

  •  進入 IIS管理器權限,點擊右邊的允許用戶,https://img2018.cnblogs.com/blog/1168541/201907/1168541-20190714155808858-2128068998.png,選擇下面的IIS管理器,添加你的IIS用戶,

 

  •  在你的網站上右鍵,點擊編輯權限->安全->編輯->添加,添加Users用戶權限爲完全控制,添加IIS_IUSRS爲完全控制(ps:第一個是爲了讓你有權限發佈文件到站點目錄,第二個是爲了預防以後出現權限不對的問題,具體的我忘了)
  •  到這裏,基本配置就完成了
  •  如果你的服務器開啓了防火牆的話,還需要注意將 Web Management之類的進程設置爲允許通過(具體名稱忘了,我這裏沒有出現那個進程);

. Visual studio 中的publish配置

  •  在要發佈的項目上右鍵,點擊publish,如果之前沒有創建publish的配置文件,那麼這裏需要創建一個配置文件
  • 選擇IISFPTetc選項,創建一個配置文件,在publish method中選擇web deploy
  • https://img2018.cnblogs.com/blog/1168541/201907/1168541-20190714153359410-1327152134.png
  •  server中填入你想要發佈到的服務器的IPsite name是你要發佈的站點的name,這個name使用IIS中創建的網站的name,賬號名和密碼是你登陸部署服務器的賬號密碼,最後一個URL是你發佈之後用於訪問該網站的鏈接
  •  填完之後,先點擊https://img2018.cnblogs.com/blog/1168541/201907/1168541-20190714153632074-813937432.png進行鏈接測試,一般來說只要你的IIS服務器配置完整,基本直接就是綠勾,如果出現了黃色歎號,莫急,後面給出我的解決方案;
  •  點擊下一步,然後就是配置一些選項,這些依據各自項目的需要進行配置。
  • 最後點擊publish即可,需要注意的是,如果你從文件資源管理器刪除了你項目中的文件,但是沒有從Visual studio中刪除,那麼publish的時候是會報錯的,只需要從Visual studio中刪除對應文件即可

, 常見報錯解決

  •  如果你有時間的話呢,可以詳細看看 https://docs.microsoft.com/en-us/iis/publish/troubleshooting-web-deploy/troubleshooting-web-deploy-problems-with-visual-studio 官方給出的一些問題解決方案
  1. could not connect to the remote computer("xxxxx") using the specified process (" Web Management Service ") because the server did not respond Make sure that the process (" Web Management Service ") is started on the remote computer xxxxx

https://img2018.cnblogs.com/blog/1168541/201907/1168541-20190714161403463-1326432255.png

 

    •  這個報錯就是說你連不上遠程部署服務器,首先檢查網絡連接以及賬號密碼什麼的
    • 檢查你遠程服務器的 Windows Deployment Services Server 服務正常運行,或者對其進行重啓
    • 如果你沒有這個服務,或者啓動不了,嘗試回到 服務器配置 章節重新安裝web deploy
    • 檢查服務器配置章節中提到的IP過濾規則,以及端口號,權限問題,
    • 如果依然報相同的錯誤,請嘗試Google
  1. connected to the remote computer ("XXX") using the Web Management Service,but could not authorize,Make suere that you are using the correct user name

  and password that the site you are connecting to exists, and that the crederitals represent a user who has permissions th access the site..

  https://img2018.cnblogs.com/blog/1168541/201907/1168541-20190714161850334-1531041159.png

 

    •  這個報錯主要是權限問題,請嘗試回到 服務器配置的權限設置部分,正確添加用戶權限

3. 

Web deployment task failed. ((2019/7/13 19:26:43) An error occurred when the request was processed on the remote computer.)

 

2019/7/13 19:24:27

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.VisualStudio.Web.Publish.PublishService.VsWebProjectPublish.<>c__DisplayClass43_0.<PublishAsync>b__2()

   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.VisualStudio.ApplicationCapabilities.Publish.ViewModel.ProfileSelectorViewModel.<RunPublishTaskAsync>d__127.MoveNext()

---> (Inner Exception #0) System.Exception: Build failed. Check the Output window for more details.<---

 

===================

 

  我在發佈的時候遇到了一個新的報錯,而且難受的是報錯信息沒有任何提示,經過嘗試後,懷疑是權限問題,在網站上右鍵,編輯權限,將網站目錄設置爲EveryOne可訪問,經過我嘗試,設置Users可以完全訪問即可成功發佈,

當然,你要是按照我上面寫的服務器配置路線走過來,應該是不會遇到這個錯誤的

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章