2021年8月11日 星期三

[研究][Gitea + Jenkins + Fortify SCA]此專案參考這部電腦上所缺少的 NuGet 套件。請啟用 NuGet 套件還原

[研究][Gitea + Jenkins + Fortify SCA]此專案參考這部電腦上所缺少的 NuGet 套件。請啟用 NuGet 套件還原

2021-08-10

簽入程式碼到 Git Server ( Gitea ),觸發 Jenkins 叫  Micro Focus Fortify SCA ( Static Code Analyzer ) 做原始碼安全性掃描 ( 源碼掃描 ),結果出現錯誤,JenKins 的 Console 畫面如下:

********************************************************************************

由遠端主機 [0:0:0:0:0:0:0:1] 啟動

Running as SYSTEM

建置中 工作區 D:\Jenkins\workspace\MyWebApplicationJob

The recommended git tool is: NONE

using credential 6f061234-4d34-12fd-8d77-210523486289

Cloning the remote Git repository

Cloning repository http://192.168.128.100:3000/MyRepos/MyWebApplicationRepo.git

 > C:\Program Files\Git\cmd\git.exe init D:\Jenkins\workspace\MyWebApplicationJob # timeout=10

Fetching upstream changes from http://192.168.128.100:3000/MyRepos/MyWebApplicationRepo.git

 > C:\Program Files\Git\cmd\git.exe --version # timeout=10

 > git --version # 'git version 2.31.1.windows.1'

using GIT_ASKPASS to set credentials 

 > C:\Program Files\Git\cmd\git.exe fetch --tags --force --progress -- http://192.168.128.100:3000/MyRepos/MyWebApplicationRepo.git +refs/heads/*:refs/remotes/origin/* # timeout=10

 > C:\Program Files\Git\cmd\git.exe config remote.origin.url http://192.168.128.100:3000/MyRepos/MyWebApplicationRepo.git # timeout=10

 > C:\Program Files\Git\cmd\git.exe config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10

Avoid second fetch

 > C:\Program Files\Git\cmd\git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10

Checking out Revision c3d6b6ca3baebf2b48c1888cb056d9395746aeff (refs/remotes/origin/master)

 > C:\Program Files\Git\cmd\git.exe config core.sparsecheckout # timeout=10

 > C:\Program Files\Git\cmd\git.exe checkout -f c3d6b6ca3baebf2b48c1888cb056d9395746aeff # timeout=10

Commit message: "test"

First time build. Skipping changelog.

No emails were triggered.

[MyWebApplicationJob] $ cmd /c call C:\Users\ADMINI~1\AppData\Local\Temp\jenkins323591801080432531.bat


D:\Jenkins\workspace\MyWebApplicationJob>D:\BuildTool\nuget.exe restore .\MyWebApplication\MyWebApplication.sln 

MSBuild auto-detection: using msbuild version '16.10.2.30804' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin'.

Restoring NuGet package ckeditor-full.4.16.1.

Restoring NuGet package MailKit.2.14.0.

Restoring NuGet package elmah.corelibrary.1.2.2.

Restoring NuGet package jQuery.3.6.0.

Restoring NuGet package Antlr.3.5.0.2.

Restoring NuGet package jQuery.UI.Combined.1.12.1.

Restoring NuGet package EntityFramework.6.4.4.

Restoring NuGet package elmah.1.2.2.

Adding package 'Antlr.3.5.0.2' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Adding package 'ckeditor-full.4.16.1' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Adding package 'elmah.1.2.2' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Adding package 'jQuery.UI.Combined.1.12.1' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Adding package 'jQuery.3.6.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Adding package 'elmah.corelibrary.1.2.2' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Adding package 'MailKit.2.14.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Adding package 'EntityFramework.6.4.4' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Added package 'elmah.corelibrary.1.2.2' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Added package 'elmah.1.2.2' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Restoring NuGet package Microsoft.AspNet.Identity.EntityFramework.2.2.3.

Restoring NuGet package Microsoft.AspNet.Identity.Core.2.2.3.

Added package 'Antlr.3.5.0.2' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Restoring NuGet package Microsoft.AspNet.Identity.EntityFramework.zh-Hant.2.2.3.

Adding package 'Microsoft.AspNet.Identity.Core.2.2.3' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Adding package 'Microsoft.AspNet.Identity.EntityFramework.2.2.3' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Adding package 'Microsoft.AspNet.Identity.EntityFramework.zh-Hant.2.2.3' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Added package 'Microsoft.AspNet.Identity.EntityFramework.2.2.3' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Restoring NuGet package Microsoft.AspNet.Identity.Owin.2.2.3.

Added package 'Microsoft.AspNet.Identity.EntityFramework.zh-Hant.2.2.3' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Restoring NuGet package Microsoft.AspNet.Web.Optimization.1.1.3.

Adding package 'Microsoft.AspNet.Identity.Owin.2.2.3' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Added package 'Microsoft.AspNet.Identity.Core.2.2.3' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Restoring NuGet package Microsoft.Owin.4.2.0.

Added package 'jQuery.UI.Combined.1.12.1' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Restoring NuGet package Microsoft.Owin.Host.SystemWeb.4.2.0.

Adding package 'Microsoft.AspNet.Web.Optimization.1.1.3' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Added package 'Microsoft.AspNet.Identity.Owin.2.2.3' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Restoring NuGet package Microsoft.Owin.Security.4.2.0.

Added package 'jQuery.3.6.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Restoring NuGet package Microsoft.Owin.Security.Cookies.4.2.0.

Adding package 'Microsoft.Owin.4.2.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Adding package 'Microsoft.Owin.Host.SystemWeb.4.2.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Added package 'Microsoft.AspNet.Web.Optimization.1.1.3' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Restoring NuGet package Microsoft.Owin.Security.OAuth.4.2.0.

Adding package 'Microsoft.Owin.Security.Cookies.4.2.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Adding package 'Microsoft.Owin.Security.4.2.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Adding package 'Microsoft.Owin.Security.OAuth.4.2.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Added package 'Microsoft.Owin.Security.Cookies.4.2.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Restoring NuGet package Microsoft.Web.Infrastructure.1.0.0.

Added package 'Microsoft.Owin.4.2.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Restoring NuGet package MimeKit.2.14.0.

Adding package 'MimeKit.2.14.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Added package 'Microsoft.Owin.Host.SystemWeb.4.2.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Restoring NuGet package Newtonsoft.Json.13.0.1.

Adding package 'Microsoft.Web.Infrastructure.1.0.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Added package 'Microsoft.Owin.Security.4.2.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Restoring NuGet package Owin.1.0.0.

Adding package 'Newtonsoft.Json.13.0.1' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Adding package 'Owin.1.0.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Added package 'Microsoft.Web.Infrastructure.1.0.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Restoring NuGet package Portable.BouncyCastle.1.8.10.

Added package 'Owin.1.0.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Restoring NuGet package System.Buffers.4.5.1.

Adding package 'System.Buffers.4.5.1' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Adding package 'Portable.BouncyCastle.1.8.10' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Added package 'Microsoft.Owin.Security.OAuth.4.2.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Restoring NuGet package WebGrease.1.6.0.

Adding package 'WebGrease.1.6.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Added package 'System.Buffers.4.5.1' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Added package 'MimeKit.2.14.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Added package 'WebGrease.1.6.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Added package 'Portable.BouncyCastle.1.8.10' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Added package 'ckeditor-full.4.16.1' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Added package 'Newtonsoft.Json.13.0.1' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Added package 'MailKit.2.14.0' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'

Added package 'EntityFramework.6.4.4' to folder 'D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages'


NuGet Config files used:

    C:\Users\Administrator\AppData\Roaming\NuGet\NuGet.Config

    C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config


Feeds used:

    C:\Users\Administrator\.nuget\packages\

    https://api.nuget.org/v3/index.json

    C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\


Installed:

    25 package(s) to packages.config projects


D:\Jenkins\workspace\MyWebApplicationJob>exit 0 

Path To MSBuild.exe: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\amd64\msbuild.exe

Executing the command cmd.exe /C " "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\amd64\msbuild.exe" .\MyWebApplication\MyWebApplication.sln " && exit %%ERRORLEVEL%% from D:\Jenkins\workspace\MyWebApplicationJob

[MyWebApplicationJob] $ cmd.exe /C " "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\amd64\msbuild.exe" .\MyWebApplication\MyWebApplication.sln " && exit %%ERRORLEVEL%%

Microsoft (R) Build Engine for .NET Framework 16.10.2+857e5a733 版

Copyright (C) Microsoft Corporation. 著作權所有,並保留一切權利。


在此解決方案中一次建置一個專案。若要啟用平行建置,請新增 "-m" 參數。

已經開始建置於 2021/8/10 下午 9:07:12。

節點 1 (預設目標) 上的專案 "D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\MyWebApplication.sln"。

ValidateSolutionConfiguration:

  建置方案組態 "Debug|Any CPU"。

專案 "D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\MyWebApplication.sln" (1) 正在節點 1 (預設目標) 上建置 "D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\MyWebApplication\MyWebApplication.csproj" (2)。

D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\MyWebApplication\MyWebApplication.csproj(1163,5): error : 此專案參考這部電腦上所缺少的 NuGet 套件。請啟用 NuGet 套件還原,以下載該套件。如需詳細資訊,請參閱 http://go.microsoft.com/fwlink/?LinkID=322105缺少的檔案是 ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props。

_CleanRecordFileWrites:

  正在建立目錄 "obj\Debug\"。

專案 "D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\MyWebApplication\MyWebApplication.csproj" (預設目標) 建置完成 -- 失敗。

專案 "D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\MyWebApplication.sln" (預設目標) 建置完成 -- 失敗。


建置失敗。


"D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\MyWebApplication.sln" (預設目標) (1) ->

"D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\MyWebApplication\MyWebApplication.csproj" (預設目標) (2) ->

(EnsureNuGetPackageBuildImports 目標) -> 

  D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\MyWebApplication\MyWebApplication.csproj(1163,5): error : 此專案參考這部電腦上所缺少的 NuGet 套件。請啟用 NuGet 套件還原,以下載該套件。如需詳細資訊,請參閱 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的檔案是 ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props。


    0 個警告

    1 個錯誤


經過時間 00:00:00.84

Build step 'Build a Visual Studio project or solution using MSBuild' marked build as failure

Sending e-mails to: (略)@(略).(略).tw

No emails were triggered.

Finished: FAILURE

********************************************************************************

解決:

對套件還原錯誤進行疑難排解
http://go.microsoft.com/fwlink/?LinkID=322105
https://docs.microsoft.com/zh-tw/nuget/Consume-Packages/Package-restore-troubleshooting

先不管上面參考資訊,直接看 MyWebApplication 方案的 packages.config 中,並沒有 Microsoft.CodeDom.Providers.DotNetCompilerPlatform,而且 NuGet 提供到 3.6.0 版

NuGet Gallery | Microsoft.CodeDom.Providers.DotNetCompilerPlatform 3.6.0
https://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/

就安裝 3.6.0 吧,再簽入一次,結果還是說缺 Microsoft.CodeDom.Providers.DotNetCompilerPlatform 2.0.1 版,拿 Visual Studio 2019 隨便新建一個 WebFrom WebApplication 方案,把 packages 目錄下的 Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1 整個複製到 Gitea + Jenkins + Fortify SCA Server 上 D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages 目錄,手動執行 Jenkins 的「馬上建置」,結果說缺另一個套件。

其他幾個方案都沒有在喊缺套件,順利建置,這個特別搗蛋。

比對了一下,Jenkins 自動抓下的只有二十幾個套件,但未簽入的有六十幾個,乾脆把 MyWebApplication 方案的整個 packages 目錄內容,拷貝到 Server 上 D:\Jenkins\workspace\MyWebApplicationJob\MyWebApplication\packages 目錄中,手動執行 Jenkins 的「馬上建置」,這次順利跑完。

此文做個紀錄,解決方法僅供參考,不保證是最正確、最好的解決方法。

(完)

相關

[研究]Jenkins作業(Job)組態的Dependency-Track(DT)設定
https://shaurong.blogspot.com/2022/09/jenkinsjobdependency-trackdt.html

[研究]Git上傳、Jenkins自動編譯、發佈 ASP.NET WebForms方案/專案到目的網站根目錄
https://shaurong.blogspot.com/2022/09/gitjenkins-aspnet-webforms.html

[研究][ASP.NET]MSBuild 17.3.1 語法參數說明
https://shaurong.blogspot.com/2022/09/aspnetmsbuild-1731.html

[研究][BAT]從Jenkins拷貝 Fortify SCA 報告
https://shaurong.blogspot.com/2022/03/batjenkins-fortify-sca.html

[研究]Jenkins 找不到 .NET SDK 'Microsoft.NET.Sdk.Web'
https://shaurong.blogspot.com/2022/02/jenkins-net-sdk-microsoftnetsdkweb.html

[研究]Jenkins : error MSB4100 條件 必須評估為布林值
https://shaurong.blogspot.com/2022/02/jenkins-error-msb4100.html

[研究]Jenkins + Fortify SCA,因 Visual Studio 2019 升級 2022,變更 MSBuild 目錄
https://shaurong.blogspot.com/2022/01/jenkins-fortify-sca-visual-studio-2019.html

[研究]疑似 Fortify SCA 或 Jenkins 產生的殘檔
https://shaurong.blogspot.com/2021/11/fortify-sca-jenkins.html

[研究][Gitea + Jenkins + Fortify SCA]此專案參考這部電腦上所缺少的 NuGet 套件。請啟用 NuGet 套件還原
https://shaurong.blogspot.com/2021/08/gitea-jenkins-fortify-sca-nuget-nuget.html

[研究] OWASP Dependency-Track 4.2.2 第三方元件安全管理安裝 (Ubuntu 20.04.2 LTS x64)
https://shaurong.blogspot.com/2021/07/owasp-dependency-track-422-ubuntu-20042.html

[研究]Jenkins 2.289.2-1.1 stable 安裝(CentOS 8.4 x64)
https://shaurong.blogspot.com/2021/07/jenkins-22892-11-stable-centos-84-x64.html

[研究] Jenkins 建置失敗
https://shaurong.blogspot.com/2021/04/jenkins.html

[研究] Jenkins 2.190.3 舊主機搬移到新主機(Win2019)
https://shaurong.blogspot.com/2019/12/jenkins-21903-win2019.html

[研究] Jenkins 2.121.1 LTS + JDK 8 + Maven 3.5.3 安裝 (Windows 2016)
https://shaurong.blogspot.com/2018/06/jenkins-21211-lts-jdk-maven-windows-2016.html

[研究] Jenkins 2.121.1 LTS + JDK 安裝 (Windows 2016)
https://shaurong.blogspot.com/2018/06/jenkins-21211-lts-jdk-windows-2016.html

[研究] Jenkins 2.128 Weekly 安裝 (Windows 2016)
https://shaurong.blogspot.com/2018/06/jekins-2128-weekly-windows-2016.html

[研究] Jenkins 2.121.1 LTS 安裝 (Windows 2016)
https://shaurong.blogspot.com/2018/06/jekins-21211-lts-windows-2016.html

[研究] Jenkins 2.68.1-1 安裝 (CentOS 7.3 x64)
https://shaurong.blogspot.com/2017/07/jenkins-2681-1-centos-73-x64.html

[研究] Jenkins 1.635 安裝 (CentOS 7.1 x64)
https://shaurong.blogspot.com/2015/10/jenkins-1635-centos-71-x64.html

[研究] Jenkins 1.635 安裝 (Windows 2012 R2)
https://shaurong.blogspot.com/2015/10/jenkins-1635-windows-2012-r2.html


沒有留言:

張貼留言