公司因為TFS Build Service無法存取網際網路還原NuGet Package,故我們採取將NuGet Packages一律簽入TFS的策略。近日再發現TFS Build Service行為特性一則,筆記之。

某專案使用Build Service編譯時出現NuGet無法還原錯誤,想起專案本次改版時更新NLog版本到4.2.3,趕緊手動補簽入NLog,但編譯持續出錯,疑惑NLog.dll已補為何還是編譯失敗,追了一陣找出答案,專案除了更新NLog,還增加了兩個Package,在專案加入NLog.config以及NLog.xsd:
<package id="NLog.Config" version="4.2.3" targetFramework="net45" />
<package id="NLog.Schema" version="4.0.0" targetFramework="net45" />

當我們講「Build Sevice」、「編譯」,腦中只想到該有的DLL要有,參照不到會編譯失敗。實際上,還原NuGet Packages是建置.NET專案的必要程序,即使cs編譯成DLL的過程用不到NLog.config跟NLog.xsd,但因為它是建置的先期步驟,遇上缺少Package又無法網頁下載補足,就會被判定錯誤導致建置程序中止。

從不覺得NLog.Schema會與編譯有關,遺漏沒簽入導致本次的狀況,問題則在補上NLog.Schema後消失。

補充:由Build Log可以判斷缺少NuGet Package,但不會指出缺少哪一個Package,感覺該寫個小工具協助檢查,嗯,排入ToDo Job Queue,排隊序號57… XD

12>RestorePackages:
     All packages listed in packages.config are already installed.
13>D:\Works\1\XAPP\XAPPWeb-Test\src\.nuget\NuGet.targets(89,9): error : Package restore is disabled by default. To give consent, open the Visual Studio Options dialog, click on Package Manager node and check 'Allow NuGet to download missing packages during build.' You can also give consent by setting the environment variable 'EnableNuGetPackageRestore' to 'true'. [D:\Works\1\XAPP\XAPPWeb-Test\src\Web\XAPPDbService\XAPPDbService.csproj]
13>D:\Works\1\XAPP\XAPPWeb-Test\src\.nuget\NuGet.targets(89,9): error MSB3073: The command ""D:\Works\1\XAPP\XAPPWeb-Test\src\.nuget\NuGet.exe" install "D:\Works\1\XAPP\XAPPWeb-Test\src\Web\XAPPDbService\packages.config" -source ""  -NonInteractive -RequireConsent -solutionDir "D:\Works\1\XAPP\XAPPWeb-Test\src\ " " exited with code 1. [D:\Works\1\XAPP\XAPPWeb-Test\src\Web\XAPPDbService\XAPPDbService.csproj]
13>Done Building Project "D:\Works\1\XAPP\XAPPWeb-Test\src\Web\XAPPDbService\XAPPDbService.csproj" (default targets) -- FAILED.


Comments

Be the first to post a comment

Post a comment


81 - 81 =