2022年2月26日 星期六

[研究][ASP.NET WebForm C#]RestSharp 106.15.0 呼叫 Web API、REST/RESTful API 測試

[研究][ASP.NET WebForm C#]RestSharp v106.x 呼叫 Web API、REST/RESTful API 測試

2022-02-26

RestSharp is REST API client library for .NET

Visual Studio2022 v17.1.0 + ASP.NET + C# + Web Application + WebForm

請用 NuGet 安裝 RestSharp 106 套件 (v107 語法大改)

Default.aspx


<%@ Page Language="C#" AutoEventWireup="true" 
    CodeBehind="Default.aspx.cs" Inherits="RestSharp106Test.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
        </div>
    </form>
    <asp:Label ID="Label1" runat="server"></asp:Label>
</body>
</html>


Default.aspx.cs


using RestSharp;
using System;
using System.Collections.Generic;

namespace RestSharp106Test
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string username = "帳號";
            string password = "密碼";
            VerifyResult content = Verify(username, password);
            Label1.Text = content.message;  // Return Code
            string contactName = content.data[0].contact_name;
} public static VerifyResult Verify(string account, string password) { var client = new RestClient("https://網址/rest/verify"); var request = new RestRequest(Method.POST); RestResponse<VerifyResult> response2; request.AddParameter("account", account); request.AddParameter("pass", password); try { //var aa = client.Execute(request); response2 = (RestSharp.RestResponse<VerifyResult>)client.Execute<VerifyResult>(request); } catch (Exception) { throw; } return response2.Data; } public class VerifyResult { public string message { get; set; } public string describe { get; set; } public List<VerifyData> data { get; set; } } public class VerifyData { public string contact_account { get; set; } public string contact_name { get; set; } public string contact_cellphone { get; set; } public string contact_mail { get; set; } public string contact_dept { get; set; } public string contact_tel { get; set; } public string contact_extend { get; set; } public string status { get; set; } public List<string> contact_category { get; set; } }
} }


(完)

相關

[研究][ASP.NET WebForm C#]RestSharp 106.15.0 呼叫 Web API、REST/RESTful API 測試https://shaurong.blogspot.com/2022/02/aspnet-webform-crestsharp-106150-web.html

RestSharp Next (v107) | RestSharp
https://restsharp.dev/v107/#restsharp-v107

NuGet Gallery | RestSharp
https://www.nuget.org/packages/RestSharp/

RestSharp - Simple .NET REST Client - GitHub
https://github.com/restsharp/RestSharp

[研究][ASP.NET WebForm C#]Newtonsoft.Json 13.0.1 序列化、反序列化測試https://shaurong.blogspot.com/2022/02/aspnet-webform-cnewtonsoftjson-1301.html

[研究][ASP.NET WebForm C#]HttpClient 呼叫 Web API、REST/RESTful API 測試(二)
https://shaurong.blogspot.com/2022/02/aspnet-webform-chttpclient-web_26.html

[研究][ASP.NET WebForm C#]HttpClient 呼叫 Web API、REST/RESTful API 測試(一)
http://shaurong.blogspot.com/2022/02/aspnet-webform-chttpclient-web.html

[研究][ASP.NET WebForm C#]WebClient 呼叫 Web API、REST/RESTful API 測試https://shaurong.blogspot.com/2022/02/aspnet-webform-cwebclient-web.html


[研究][ASP.NET WebForm C#]Newtonsoft.Json 13.0.1 序列化、反序列化測試

[研究][ASP.NET WebForm C#]Newtonsoft.Json 13.0.1 序列化、反序列化測試

2022-02-26

續這篇

[研究][ASP.NET WebForm C#]HttpClient 呼叫 Web API、REST/RESTful API 測試(二)
https://shaurong.blogspot.com/2022/02/aspnet-webform-chttpclient-web_26.html

Visual Studio2022 v17.1.0 + ASP.NET + C# + Web Application + WebForm

Default.aspx


<%@ Page Language="C#" AutoEventWireup="true" 
CodeBehind="Default.aspx.cs" Inherits="WebApplication4.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
        </div>
    </form>
    <asp:Label ID="Label_MSG1" runat="server"></asp:Label><br />
    <asp:Label ID="Label_MSG2" runat="server"></asp:Label><br />
    <asp:Label ID="Label_MSG3" runat="server"></asp:Label><br />
</body>
</html>

Default.aspx.cs


using Newtonsoft.Json;
using System;
using System.Collections.Generic;

namespace WebApplication4
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            JSONTest();
        }
        public class Student
        {
            public int ID { get; set; }
            public string CName { get; set; }
            public int Age { get; set; }
            public string Sex { get; set; }
        }
        
        protected void JSONTest()
        {
            List<Student> listStudentSample = new List<Student>()
            {
                new Student(){ID=1,CName="John",Age=21,Sex="男"},
                new Student(){ID=2,CName="Mary",Age=29,Sex="女"}
            };

            //Newtonsoft.Json序列化
            string jsonData = JsonConvert.SerializeObject(listStudentSample);
            Label_MSG1.Text= jsonData;

            foreach(Student student in listStudentSample)
            {
                Label_MSG1.Text = Label_MSG1.Text + "<br />" 
                    + JsonConvert.SerializeObject(student);//序列化
            }
            Label_MSG1.Text = Label_MSG1.Text +  "<br />----------<br />";

            //Newtonsoft.Json反序列化
            string json = @"{ 'CName':'Alice','Age':'30','ID':'1','Sex':'女'}";
            Label_MSG2.Text = json;
            Student stu = JsonConvert.DeserializeObject<Student>(json);//反序列化
            Label_MSG3.Text = stu.CName;
        }
    }
}

但目前 class Student 中資料型態都是基本型態,不是 Class;

Newtonsoft.Json 沒有直接支援巢狀反序列化。

(完)

相關

RestSharp Next (v107) | RestSharp
https://restsharp.dev/v107/#restsharp-v107

NuGet Gallery | RestSharp
https://www.nuget.org/packages/RestSharp/

RestSharp - Simple .NET REST Client - GitHub
https://github.com/restsharp/RestSharp

[研究][ASP.NET WebForm C#]Newtonsoft.Json 13.0.1 序列化、反序列化測試https://shaurong.blogspot.com/2022/02/aspnet-webform-cnewtonsoftjson-1301.html

[研究][ASP.NET WebForm C#]HttpClient 呼叫 Web API、REST/RESTful API 測試(二)
https://shaurong.blogspot.com/2022/02/aspnet-webform-chttpclient-web_26.html

[研究][ASP.NET WebForm C#]HttpClient 呼叫 Web API、REST/RESTful API 測試(一)
http://shaurong.blogspot.com/2022/02/aspnet-webform-chttpclient-web.html

[研究][ASP.NET WebForm C#]WebClient 呼叫 Web API、REST/RESTful API 測試https://shaurong.blogspot.com/2022/02/aspnet-webform-cwebclient-web.html


[研究][ASP.NET WebForm C#]HttpClient 呼叫 Web API、REST/RESTful API、JSON字串轉JSON Objection 測試(二)

[研究][ASP.NET WebForm C#]HttpClient 呼叫 Web API、REST/RESTful API、JSON字串轉JSON Objection 測試(二)

2022-02-26

續這篇

[研究][ASP.NET WebForm C#]HttpClient 呼叫 Web API、REST/RESTful API 測試(一)
http://shaurong.blogspot.com/2022/02/aspnet-webform-chttpclient-web.html

後來發現

HttpClient 類別
https://docs.microsoft.com/zh-tw/dotnet/api/system.net.http.httpclient?view=net-6.0&WT.mc_id=DOP-MVP-37580&viewFallbackFrom=netframework-4
HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
HttpClient 應該只建立一份並重複利用。為每次請求建立新的 HttpClient,重度使用下可能用光 Socket Port 導致 SocketException。以下是正確的寫法:

Visual Studio2022 v17.1.0 + ASP.NET + C# + Web Application + WebForm

Default.aspx


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" 
Inherits="WebApplication1.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            
        </div>
    </form>
    <asp:Label ID="Label_MSG1" runat="server" Text="Label"></asp:Label>
</body>
</html>

Default.aspx.cs


using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;

namespace WebApplication1
{
    public partial class Default : System.Web.UI.Page
    {
        public static readonly HttpClient client = new HttpClient();
        protected void Page_Load(object sender, EventArgs e)
        {
            _ = CallWebAPI();
        }
        protected Task CallWebAPI()
        {
            string account = "帳號";
            string password = "密碼";
            var values = new[]
            {
                new KeyValuePair<string, string>("account", account),
                new KeyValuePair<string, string>("pass", password)
            };
            try
            {
                using (FormUrlEncodedContent multipartFormDataContent =
                    new FormUrlEncodedContent(values))
                {
                    //HttpResponseMessage response =
                    //    await client.PostAsync("https://網址/rest/verify", 
                    //        multipartFormDataContent);
                    //response.EnsureSuccessStatusCode();
                    //string responseBody = await response.Content.ReadAsStringAsync();
                    //string responseBody = await response.Content.ReadAsStringAsync();
                    //Label_MSG1.Text = responseBody;

                    var requestUri = "https://網址/rest/verify";
var json = client.PostAsync(requestUri, multipartFormDataContent).Result.Content.ReadAsStringAsync().Result; JObject jo = Newtonsoft.Json.Linq.JObject.Parse(json); string message = jo["message"].ToString(); string data = jo["data"].ToString(); string contact_account = jo["data"]["contact_account"].ToString(); Label_MSG1.Text = json;
// Above three lines can be replaced with new helper method below // string responseBody = await client.GetStringAsync(uri); } } catch (HttpRequestException ex) { Label_MSG1.Text = "不明錯誤。"; if (ex != null) Label_MSG1.Text = ex.Message.ToString(); } return Task.CompletedTask; } } }


(完)

相關

RestSharp Next (v107) | RestSharp
https://restsharp.dev/v107/#restsharp-v107

NuGet Gallery | RestSharp
https://www.nuget.org/packages/RestSharp/

RestSharp - Simple .NET REST Client - GitHub
https://github.com/restsharp/RestSharp

[研究][ASP.NET WebForm C#]Newtonsoft.Json 13.0.1 序列化、反序列化測試https://shaurong.blogspot.com/2022/02/aspnet-webform-cnewtonsoftjson-1301.html

[研究][ASP.NET WebForm C#]HttpClient 呼叫 Web API、REST/RESTful API 測試(二)
https://shaurong.blogspot.com/2022/02/aspnet-webform-chttpclient-web_26.html

[研究][ASP.NET WebForm C#]HttpClient 呼叫 Web API、REST/RESTful API 測試(一)
http://shaurong.blogspot.com/2022/02/aspnet-webform-chttpclient-web.html

[研究][ASP.NET WebForm C#]WebClient 呼叫 Web API、REST/RESTful API 測試https://shaurong.blogspot.com/2022/02/aspnet-webform-cwebclient-web.html


[研究][ASP.NET WebForm C#]HttpClient 呼叫 Web API、REST/RESTful API 測試(一)

[研究][ASP.NET WebForm C#]HttpClient 呼叫 Web API、REST/RESTful API 測試(一)

2022-02-26

續這篇

[研究][ASP.NET WebForm C#]WebClient 呼叫 Web API、REST/RESTful API 測試
https://shaurong.blogspot.com/2022/02/aspnet-webform-cwebclient-web.html

Visual Studio2022 v17.1.0 + ASP.NET + C# + Web Application + WebForm

Default.aspx


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" 
Inherits="WebApplication1.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
        </div>
    </form>
    <asp:Label ID="Label_MSG1" runat="server" Text="Label"></asp:Label>
</body>
</html>

Default.aspx.cs


using System;
using System.Collections.Generic;
using System.Net.Http;

namespace WebApplication2
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            // WebRequest、WebClient 和 >servicepoint 已淘汰
            // https://docs.microsoft.com/zh-tw/dotnet/core/compatibility/networking/6.0/webrequest-deprecated
            // 請改用 System.Net.Http.HttpClient 類別。

            MultipartFormDataContent content = new MultipartFormDataContent();
            using (HttpClient client = new HttpClient())
            {
                //client.DefaultRequestHeaders.Add("");
                string account = "帳號";
                string password = "密碼";
                var values = new[]
                {
                    new KeyValuePair<string, string>("account", account),
                    new KeyValuePair<string, string>("pass", password)
                };
                using (FormUrlEncodedContent multipartFormDataContent = new FormUrlEncodedContent(values))
                {
                    var requestUri = "https://網址/rest/verify";
                    var json = client.PostAsync(requestUri, multipartFormDataContent).Result.Content.ReadAsStringAsync().Result;
                    Label_MSG1.Text = json;
					
		    //VerifyResult vResult = JsonConvert.DeserializeObject<VerifyResult>(json);
					
		    //JavaScriptSerializer js = new JavaScriptSerializer();
                    //VerifyResult info = js.Deserialize<VerifyResult>(html);
                }
            }
        }
    }
}

後來發現

HttpClient 類別
https://docs.microsoft.com/zh-tw/dotnet/api/system.net.http.httpclient?view=net-6.0&WT.mc_id=DOP-MVP-37580&viewFallbackFrom=netframework-4
HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
HttpClient 應該只建立一份並重複利用。為每次請求建立新的 HttpClient,重度使用下可能用光 Socket Port 導致 SocketException。以下是正確的寫法:

(完)

相關

[研究][ASP.NET WebForm C#]HttpClient 呼叫 Web API、REST/RESTful API 測試(二)
https://shaurong.blogspot.com/2022/02/aspnet-webform-chttpclient-web_26.html

[研究][ASP.NET WebForm C#]HttpClient 呼叫 Web API、REST/RESTful API 測試(一)
http://shaurong.blogspot.com/2022/02/aspnet-webform-chttpclient-web.html

[研究][ASP.NET WebForm C#]WebClient 呼叫 Web API、REST/RESTful API 測試https://shaurong.blogspot.com/2022/02/aspnet-webform-cwebclient-web.html


[研究][ASP.NET WebForm C#]WebClient 呼叫 Web API、REST/RESTful API 測試

[研究][ASP.NET WebForm C#]WebClient 呼叫 Web API、REST/RESTful API 測試

2022-02-26

Visual Studio2022 v17.1.0 + ASP.NET + C# + Web Application + WebForm

Default.aspx


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" 
Inherits="WebApplication1.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
        </div>
    </form>
    <asp:Label ID="Label_MSG1" runat="server" Text="Label"></asp:Label>
</body>
</html>

Default.aspx.cs


using System;
using System.Net;
using System.Text;

namespace WebApplication1
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            WebClient client = new WebClient();
            client.Encoding = Encoding.UTF8;
            client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";

            string response;
            string account = "帳號;
            string password = "密碼";

            try
            {
                response = client.UploadString("https://網址/rest/verify",
                "account=" + account + "&pass=" + password);
            }
            catch
            {
                Label_MSG1.Text = "fail";
                return;
            }
            Label_MSG1.Text = response; // JSON Format Data
        }
    }
}

後來發現

WebRequest、WebClient 和 >servicepoint 已淘汰
https://docs.microsoft.com/zh-tw/dotnet/core/compatibility/networking/6.0/webrequest-deprecated
請改用 System.Net.Http.HttpClient 類別。

(完)

相關

[研究][ASP.NET WebForm C#]HttpClient 呼叫 Web API、REST/RESTful API 測試(二)
https://shaurong.blogspot.com/2022/02/aspnet-webform-chttpclient-web_26.html

[研究][ASP.NET WebForm C#]HttpClient 呼叫 Web API、REST/RESTful API 測試(一)
http://shaurong.blogspot.com/2022/02/aspnet-webform-chttpclient-web.html

[研究][ASP.NET WebForm C#]WebClient 呼叫 Web API、REST/RESTful API 測試https://shaurong.blogspot.com/2022/02/aspnet-webform-cwebclient-web.html


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


[研究]Jenkins : error MSB4100 條件 必須評估為布林值

[研究]Jenkins : error MSB4100 條件 必須評估為布林值

2022-02-09

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

錯誤訊息:

D:\Jenkins\workspace\Fortify_WebApplication1\WebApplication1\WebApplication1\WebApplication1.csproj(9891,60): error MSB4100: 條件 "!$(Disable_CopyWebApplication) And '$(OutDir)' != '$(OutputPath)'" 中的 "!$(Disable_CopyWebApplication)" 必須評估為布林值,而非 "!"。

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

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


建置失敗。

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

解決:

好像 Visual Studio 2022 Installer 增加安裝某些 .NET SDK 後解決。

(完)

相關

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


2022年2月8日 星期二

[研究][ASP.NET]預先定義的類型 'System.ObsoleteAttribute' 在全域別名的多個組件中都有定義

[研究][ASP.NET]預先定義的類型 'System.ObsoleteAttribute' 在全域別名的多個組件中都有定義

2022-02-08

嚴重性 程式碼 說明 專案 檔案 隱藏項目狀態

警告 預先定義的類型 'System.ObsoleteAttribute' 在全域別名的多個組件中都有定義; 使用 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\mscorlib.dll' 中的定義 PMSWeb ASPNETCOMPILER 0

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

解決:

.NET Framework 中的過時功能 | Microsoft Docs
https://docs.microsoft.com/zh-tw/dotnet/framework/whats-new/whats-obsolete
這裡有 ObsoleteAttribute 屬性 相關說明

還是不知如何改;因為只是警告,雖然每次編譯都有警告,但使用上沒有異常,先不理。

(完)

[研究] Visual Studio 2022環境重設

[研究] Visual Studio 2022環境重設 

2022-02-08

不知按到鍵盤甚麼 hot key,VS2022 畫面文字變很小,要搜尋文字時,發現連框和框的文字都變小,於是想辦法回復原狀。


(下圖)一開始去「工具」下拉選單的「選項」選項,找「環境」和「專案和方案」,但沒有合適的。後來發現是「工具」下拉選單的「匯入和匯出設定」選項。

(下圖)改選「重設所有設定」,按下「下一步」按鈕。

(下圖)預防萬一,把目前設定儲存



(下圖)某些設定似乎無法還原成預設值。

********************************************************************************
後來匯入剛剛儲存的設定,依然有TypeScript那兩個錯誤。
********************************************************************************
(下圖) 後來發現這裡改回100%就解決問題。當初不小心不知按到甚麼 HotKey 變成 73% 了。

(完)


2022年2月7日 星期一

[研究][ASP.NET]RestSharp.106.13.0 升級 107.2.1 後編譯發生錯誤

[研究][ASP.NET]RestSharp.106.13.0 升級 107.2.1 後編譯發生問題

2022-02-07

RestSharp is REST API client library for .NET

NuGet RestSharp.106.13.0 -> RestSharp.107.2.1 後編譯發生問題

嚴重性 程式碼 說明 專案 檔案 隱藏項目狀態

錯誤 CS1061 'string' 未包含 'HasValue' 的定義,也找不到可接受類型 'string' 第一個引數的可存取擴充方法 'HasValue' (是否遺漏 using 指示詞或組件參考?)

錯誤 CS0117 'Method' 未包含 'POST' 的定義

錯誤 CS1061 'RestClient' 未包含 'Execute' 的定義,也找不到可接受類型 'RestClient' 第一個引數的可存取擴充方法 'Execute' (是否遺漏 using 指示詞或組件參考?)

實際問題


string localIP = GetLocalIPv4();

if ((localIP.HasValue() ...




var request = new RestRequest(Method.POST);   

     


response2 = (RestSharp.RestResponse<GetResult>)client.Execute<GetResult>(request);

暫時解決方案:不要升級

(完)

[研究][ASP.NET]在同一個相依組件的不同版本之間發現衝突

[研究][ASP.NET]在同一個相依組件的不同版本之間發現衝突

2021-12-02

環境:Visual Studio 2022 v17.0.5 + ASP.NET + WebForm + C# + Web Application

某次元件更新後,編譯出錯。

嚴重性 程式碼 說明 專案 檔案 隱藏項目狀態

警告 在同一個相依組件的不同版本之間發現衝突。請在 Visual Studio 中按兩下這個警告 (或選取後按 Enter) 解決這些衝突,或者將下列繫結重新導向加到應用程式組態檔中的 [執行階段] 節點: 


<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="AngleSharp" culture="neutral" publicKeyToken="e83494dcdc6d31ea" />
<bindingRedirect oldVersion="0.0.0.0-0.16.1.0" newVersion="0.16.1.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Antlr3.Runtime" culture="neutral" publicKeyToken="eb42632606e9261f" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Autofac" culture="neutral" publicKeyToken="17863af14b0044da" />
<bindingRedirect oldVersion="0.0.0.0-6.3.0.0" newVersion="6.3.0.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="BouncyCastle.Crypto" culture="neutral" publicKeyToken="0e99375e54769942" />
<bindingRedirect oldVersion="0.0.0.0-1.9.0.0" newVersion="1.9.0.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="DocumentFormat.OpenXml" culture="neutral" publicKeyToken="8fb06cb64d019a17" />
<bindingRedirect oldVersion="0.0.0.0-2.14.0.0" newVersion="2.14.0.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="ExcelNumberFormat" culture="neutral" publicKeyToken="23c6f5d73be07eca" />
<bindingRedirect oldVersion="0.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="ICSharpCode.SharpZipLib" culture="neutral" publicKeyToken="1b03e6acf1164f73" />
<bindingRedirect oldVersion="0.0.0.0-1.3.3.11" newVersion="1.3.3.11" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" culture="neutral" publicKeyToken="cc7b13ffcd2ddd51" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" culture="neutral" publicKeyToken="cc7b13ffcd2ddd51" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.1" newVersion="5.0.0.1" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Text.Json" culture="neutral" publicKeyToken="cc7b13ffcd2ddd51" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.2" newVersion="5.0.0.2" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" culture="neutral" publicKeyToken="cc7b13ffcd2ddd51" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
</dependentAssembly>
</assemblyBinding>
ㄐ

解決:在 Visual Studio 中按兩下這個警告 (或選取後按 Enter) 解決了。

(完)

[研究][ASP.NET] NuGet 升級 Oracle.ManagedDataAccess.21.4.0 -> Oracle.ManagedDataAccess.21.5.0

[研究][ASP.NET] NuGet 升級 Oracle.ManagedDataAccess.21.4.0 -> Oracle.ManagedDataAccess.21.5.0

2021-12-02

Oracle.ManagedDataAccess.21.4.0 -> Oracle.ManagedDataAccess.21.5.0

更新:

Microsoft.Bcl.AsyncInterfaces.5.0.0 -> Microsoft.Bcl.AsyncInterfaces.6.0.0

Oracle.ManagedDataAccess.21.4.0 -> Oracle.ManagedDataAccess.21.5.0

System.Runtime.CompilerServices.Unsafe.5.0.0 -> System.Runtime.CompilerServices.Unsafe.6.0.0

System.Text.Encodings.Web.5.0.1 -> System.Text.Encodings.Web.6.0.0

System.Text.Json.5.0.2 -> System.Text.Json.6.0.0     


已開始重建...
1>------ 已開始全部重建: 專案: WebApplication1, 組態: Debug Any CPU ------
1>  WebApplication1 -> D:\Code\WebApplication1\WebApplication1\bin\WebApplication1.dll
2>------ 已開始全部重建: 專案: WebApplication1.Tests, 組態: Debug Any CPU ------
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277: 不同版本的 "System.Runtime.CompilerServices.Unsafe" 之間發生無法解決的衝突。
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277: "System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 和 "System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 之間發生衝突。
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:     已選擇 "System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",因為它是主要組件,而 "System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 不是。
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:     相依於 "System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [D:\Code\WebApplication1\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll] 的參考。
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:         D:\Code\WebApplication1\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:           專案檔項目 Include 造成參考 "D:\Code\WebApplication1\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll" 的項目。
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:             System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:             System.Diagnostics.DiagnosticSource, Version=5.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:             System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:             D:\Code\WebApplication1\WebApplication1\bin\WebApplication1.dll
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:         D:\Code\WebApplication1\packages\System.Diagnostics.DiagnosticSource.5.0.1\lib\net46\System.Diagnostics.DiagnosticSource.dll
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:           專案檔項目 Include 造成參考 "D:\Code\WebApplication1\packages\System.Diagnostics.DiagnosticSource.5.0.1\lib\net46\System.Diagnostics.DiagnosticSource.dll" 的項目。
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:             System.Diagnostics.DiagnosticSource, Version=5.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:             D:\Code\WebApplication1\WebApplication1\bin\WebApplication1.dll
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:         D:\Code\WebApplication1\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:           專案檔項目 Include 造成參考 "D:\Code\WebApplication1\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll" 的項目。
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:             System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:             System.Diagnostics.DiagnosticSource, Version=5.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:             D:\Code\WebApplication1\WebApplication1\bin\WebApplication1.dll
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:         D:\Code\WebApplication1\WebApplication1\bin\System.Threading.Tasks.Extensions.dll
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:           專案檔項目 Include 造成參考 "D:\Code\WebApplication1\WebApplication1\bin\System.Threading.Tasks.Extensions.dll" 的項目。
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:             D:\Code\WebApplication1\WebApplication1\bin\WebApplication1.dll
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:         D:\Code\WebApplication1\WebApplication1\bin\System.Text.Encoding.CodePages.dll
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:           專案檔項目 Include 造成參考 "D:\Code\WebApplication1\WebApplication1\bin\System.Text.Encoding.CodePages.dll" 的項目。
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:             D:\Code\WebApplication1\WebApplication1\bin\WebApplication1.dll
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:     相依於 "System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [D:\Code\WebApplication1\WebApplication1\bin\System.Runtime.CompilerServices.Unsafe.dll] 的參考。
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:         D:\Code\WebApplication1\WebApplication1\bin\System.Text.Json.dll
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:           專案檔項目 Include 造成參考 "D:\Code\WebApplication1\WebApplication1\bin\System.Text.Json.dll" 的項目。
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:             D:\Code\WebApplication1\WebApplication1\bin\WebApplication1.dll
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:         D:\Code\WebApplication1\WebApplication1\bin\System.Text.Encodings.Web.dll
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:           專案檔項目 Include 造成參考 "D:\Code\WebApplication1\WebApplication1\bin\System.Text.Encodings.Web.dll" 的項目。
2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3277:             D:\Code\WebApplication1\WebApplication1\bin\WebApplication1.dll
2>  WebApplication1.Tests -> D:\Code\WebApplication1\WebApplication1.Tests\bin\Debug\WebApplication1.Tests.dll
========== 全部重建: 2 成功、0 失敗、 0 略過 ==========

後來發現方案中有2個專案,其中一個專案的  System.Runtime.CompilerServices.Unsafe.仍是  5.0.0,升級上去就解決了。

(完)