.Net Core 透過Jenkins部署的問題排除

    前一篇提到如何透過MsBuild及MsDeploy來部署,將相關指令搬到 Jenkins來執行後,出現了一些.NetCore才有的問題,例: project.lock.json is denied.。


20170309 後記,升上Vs2017就無以下問題
http://note.kimx.info/2017/03/visual-studio-2017-net-core.html

===============Vs2017 以下請忽略================

問題排除記錄


以下為在Jenkins建置時遇到問題及排除記錄。

1.project.fragment.lock.json及project.lock.json is denied.

原因:在Jenkins取下來時,檔案是唯讀的,而package restore時,需要寫入該檔案

解決方式:使用.tfignore,不要簽入tfs

SNAGHTML1b39ebc

參考連結:

https://msdn.microsoft.com/zh-tw/library/ms245454.aspx
http://stackoverflow.com/questions/39169934/generate-dependency-fragment-file-task-failed
https://www.youtube.com/watch?v=BfKcTX8NxAQ

2.***.exe.config' is denied

原因:建置成package會使用專案內的app.config,該檔案是唯讀屬性,所以轉成.exe.config時會寫入失敗。

解決方式:刪除app.config,如將app.config的設定改到project.json,如下:


image

3.reason: Access to the path ...bin\Release\net461\EntityFramework.SqlServer.dll

原因:不詳......不知為何該dll也需要寫入權限。

解決方式:在找不到參考的解決方式,最後乾脆在Jenkins向TFS取得檔案後,執行指令將目錄內的readonly屬性移除。

 建置前移除唯讀

   attrib -r "%WORKSPACE%\*.*" /s

image


  建置後將唯讀加回去

   attrib +r "%WORKSPACE%\*.*" /s

此指令若沒下,下次在取檔案時,會無法更新本地的檔案。

指令參考

http://superuser.com/questions/653951/how-to-remove-read-only-attribute-recursively-on-windows-7


Ps:使用此方式的話,上述的第1、2點可以省略.......哈...繞了一大圈。

這個網誌中的熱門文章

IIS 設定只允許特定IP進入