簡體   English   中英

Visual Studio 強制在參考程序集中使用 System.Net.Http 而不是 Nuget 中指定的那個

[英]Visual Studio forces use System.Net.Http in Reference Assembly rather than the one specified in Nuget

我在我的項目中將 System.Net.Http 引用為 nuget package,引用在 packages.config 和 .csproj 文件中是正確的,但在 Visual Studio 屬性選項卡中它總是在系統的引用程序集路徑中使用 package,有人知道為什么嗎?

另一個奇怪的是,內置的<webproj>\bin\roslyn中的這個文件有另一個版本,似乎它既沒有在 nuget 中也沒有在 Reference Assembly 中使用 dll 文件。

而實際上System.Net.Http.dll在nuget package中,在Reference Assembly中,內置的<webproj>\bin\roslyn目錄有不同的版本, <webproj>\bin\roslyn中的文件似乎使用Visual Studio目錄的文件( C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\Extensions\aqwf5fqp.2lv\System.Net.Http.dllC:\Program Files (x86)\Microsoft SDKs\NuGetnetPackages\system .http\4.3.0\runtimes\win\lib.net46\System.Net.Http.dllC:\Program Files (x86)\Microsoft SDKs\NuGetPackages\system.net.http\4.3.0\lib.net46\System .Net.Http.dll,根據版本和文件大小判斷)

dll 在不同的路徑 匯編版本
dll 在 nuget, package 版本 4.3.4 4.1.1.3
參考程序集中的 dll(又名在 VS 屬性選項卡中引用) 4.2.0.0
dll 在內置的<webproj>\bin\roslyn目錄中 4.1.1.0

在 packages.config <package id="System.Net.Http" version="4.3.4" targetFramework=.net472" />

在.csproj

    <Reference Include="System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\lib\Nugets\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll</HintPath>
      <Private>True</Private>
    </Reference>

在屬性選項卡中在此處輸入圖像描述

我想強制 VS(屬性選項卡)或 bin\roslyn 中的文件在 nuget package 中使用 dll ,請問該怎么做? 謝謝你。

您可以嘗試從 packages.config 遷移到 PackageReference

這可以幫助您在一個地方管理所有項目依賴項:就像項目到項目引用和程序集引用一樣,NuGet package 引用(使用 PackageReference 節點)直接在項目文件中管理,而不是使用單獨的 packages.config 文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM