2022年2月9日 星期三

[研究]Jenkins 找不到 .NET SDK 'Microsoft.NET.Sdk.Web'

[研究]Jenkins 找不到 .NET SDK 'Microsoft.NET.Sdk.Web'

2022-02-09

環境:JenKins + Fortify SCA ( Static Code Analyzer ) + Git Server ( gitea)

錯誤訊息:

Running as SYSTEM

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

The recommended git tool is: NONE

using credential b1d46f06-4da8-4bfd-8d49-5eecf9da2105

 > C:\Program Files\Git\cmd\git.exe rev-parse --resolve-git-dir D:\Jenkins\workspace\Fortify_WebApplication2\.git # timeout=10

Fetching changes from the remote Git repository

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

Fetching upstream changes from http://10.3.199.145:3000/WebApplication2.git

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

 > git --version # 'git version 2.33.0.windows.2'

using GIT_ASKPASS to set credentials 

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

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

Checking out Revision 5ff7aeff5afe6b505e13db2d376109d324efe2a3 (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 5ff7aeff5afe6b505e13db2d376109d324efe2a3 # timeout=10

Commit message: "fix"

 > C:\Program Files\Git\cmd\git.exe rev-list --no-walk 5ff7aeff5afe6b505e13db2d376109d324efe2a3 # timeout=10

No emails were triggered.

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


D:\Jenkins\workspace\Fortify_WebApplication2>dotnet new globaljson --sdk-version 5.0.403 

'dotnet' 不是內部或外部命令、可執行的程式或批次檔。


D:\Jenkins\workspace\Fortify_WebApplication2>dotnet add .\WebApplication2\WebApplication2.csproj package SecurityCodeScan 

'dotnet' 不是內部或外部命令、可執行的程式或批次檔。


D:\Jenkins\workspace\Fortify_WebApplication2>msbuild -t:restore .\WebApplication2.sln 

Microsoft (R) Build Engine for .NET Framework 17.0.0+c9eb9dd64 版

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


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

已經開始建置於 2022/2/9 上午 08:17:07。

節點 1 (Restore 目標) 上的專案 "D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2.sln"。

ValidateSolutionConfiguration:

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

A compatible installed .NET SDK for global.json version [5.0.403] from [D:\Jenkins\workspace\Fortify_WebApplication2\global.json] was not found.

Install the [5.0.403] .NET SDK or update [D:\Jenkins\workspace\Fortify_WebApplication2\global.json] with an installed .NET SDK:

  It was not possible to find any installed .NET SDKs.

Install a .NET SDK from:

  https://aka.ms/dotnet-download

D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2\WebApplication2.csproj : error : 找不到 .NET SDK。請檢查是否已安裝該項目,且在 global.json 中指定的版本 (如果有的話) 是否與安裝的版本相符。

D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2\WebApplication2.csproj : warning NU1503: 正在跳過還原專案 'D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2\WebApplication2.csproj'。該專案檔可能無效或缺少還原所須的目標。 [D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2.sln]

_GetAllRestoreProjectPathItems:

  正在判斷要還原的專案...

Restore:

  沒有任何動作可執行。指定的專案皆未包含可還原的套件。

專案 "D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2.sln" (Restore 目標) 建置完成。


建置成功。


"D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2.sln" (Restore 目標) (1) ->

(_FilterRestoreGraphProjectInputItems 目標) -> 

  D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2\WebApplication2.csproj : warning NU1503: 正在跳過還原專案 'D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2\WebApplication2.csproj'。該專案檔可能無效或缺少還原所須的目標。 [D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2.sln]



  D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2\WebApplication2.csproj : error : 找不到 .NET SDK。請檢查是否已安裝該項目,且在 global.json 中指定的版本 (如果有的話) 是否與安裝的版本相符。


    1 個警告

    1 個錯誤


經過時間 00:00:07.49


D:\Jenkins\workspace\Fortify_WebApplication2>exit 0 

Path To MSBuild.exe: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\bin\msbuild.exe

Executing the command cmd.exe /C " "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\bin\msbuild.exe" .\WebApplication2.sln " && exit %%ERRORLEVEL%% from D:\Jenkins\workspace\Fortify_WebApplication2

[Fortify_WebApplication2] $ cmd.exe /C " "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\bin\msbuild.exe" .\WebApplication2.sln " && exit %%ERRORLEVEL%%

Microsoft (R) Build Engine for .NET Framework 17.0.0+c9eb9dd64 版

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


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

已經開始建置於 2022/2/9 上午 08:17:16。

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

ValidateSolutionConfiguration:

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

A compatible installed .NET SDK for global.json version [5.0.403] from [D:\Jenkins\workspace\Fortify_WebApplication2\global.json] was not found.

Install the [5.0.403] .NET SDK or update [D:\Jenkins\workspace\Fortify_WebApplication2\global.json] with an installed .NET SDK:

  It was not possible to find any installed .NET SDKs.

Install a .NET SDK from:

  https://aka.ms/dotnet-download

D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2\WebApplication2.csproj : error : 找不到 .NET SDK。請檢查是否已安裝該項目,且在 global.json 中指定的版本 (如果有的話) 是否與安裝的版本相符。

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

D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2\WebApplication2.csproj : error MSB4236: 找不到指定的 SDK 'Microsoft.NET.Sdk.Web'。

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

專案 "D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2.sln" (1) 正在節點 1 (預設目標) 上建置 "D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2Db\WebApplication2Db.sqlproj" (3)。

GenerateSqlTargetFrameworkMoniker:

將略過目標 "GenerateSqlTargetFrameworkMoniker",因為所有輸出檔對於其輸入檔而言都已更新。

CoreCompile:

將略過目標 "CoreCompile",因為所有輸出檔對於其輸入檔而言都已更新。

SqlBuild:

將略過目標 "SqlBuild",因為所有輸出檔對於其輸入檔而言都已更新。

CopyFilesToOutputDirectory:

  WebApplication2Db -> D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2Db\bin\Debug\WebApplication2Db.dll

SqlPrepareForRun:

  WebApplication2Db -> D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2Db\bin\Debug\WebApplication2Db.dacpac

IncrementalClean:

  正在刪除檔案 "D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2Db\obj\Debug\Model.xml"。

專案 "D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2Db\WebApplication2Db.sqlproj" (預設目標) 建置完成。

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


建置失敗。


  D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2\WebApplication2.csproj : error : 找不到 .NET SDK。請檢查是否已安裝該項目,且在 global.json 中指定的版本 (如果有的話) 是否與安裝的版本相符。



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

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

  D:\Jenkins\workspace\Fortify_WebApplication2\WebApplication2\WebApplication2.csproj : error MSB4236: 找不到指定的 SDK 'Microsoft.NET.Sdk.Web'。


    0 個警告

    2 個錯誤


經過時間 00:00:07.66

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

Sending e-mails to: xxx@xxx.com.tw

No emails were triggered.

Finished: FAILURE

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

檢查:



因為訊息疑似說 global.json 設定 5.0.403,因為該方案非敝人負責,不能查改 global.json
A compatible installed .NET SDK for global.json version [5.0.403] from [D:\Jenkins\workspace\Fortify_WebApplication2\global.json] was not found
和
D:\Jenkins\workspace\Fortify_WebApplication2>dotnet new globaljson --sdk-version 5.0.403 

'dotnet' 不是內部或外部命令、可執行的程式或批次檔。

查一下 Jenkins 這台目前 donet. 版本是 6.0.12,沒有 5.x 版的。


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

解決:

Jenkins登入後,點選某 Job 名稱,點選左邊「組態」,搜尋 5.0.403,改成 6.0.102,再次建置,錯誤依然。

安裝 Microsoft .NET SDK 5.0.405
https://dotnet.microsoft.com/en-us/download
dotnet-sdk-5.0.405-win-x64.exe

成功,也就是 .NET SDK 6.x 無法替代 .NET SDK 5.x,5.0.45 可以替代 5.0.43。

Visual Studio 2022 只提供安裝最新版 .NET SDK,也就是 .NET SDK 6.0,

無法個別勾選是否安裝  .NET SDK 5.0 和  .NET SDK 6.0。

只能另外手動下載安裝 .NET SDK 5.0。

(完)

相關

[研究]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


沒有留言:

張貼留言