gpt4 book ai didi

.net - nuget 的程序集被 GAC 的程序集覆盖

转载 作者:行者123 更新时间:2023-12-03 20:27:29 26 4
gpt4 key购买 nike

我有一个包含 azure 云项目和辅助角色项目(+一些辅助项目)的解决方案。当我在本地调试工作程序时,出现以下异常:

Could not load file or assembly 'System.Runtime.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"System.Runtime.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

融合日志:

=== Pre-bind state information ===
LOG: DisplayName = System.Runtime.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/Azure/roles/[worker project]/approot
LOG: Initial PrivatePath = C:\Azure\roles\[worker project]\approot
Calling assembly : Microsoft.Extensions.Configuration, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Azure\roles\[worker project]\approot\[worker assembly].dll.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 4.0.0.0 redirected to 4.1.1.0.
LOG: Post-policy reference: System.Runtime.Extensions, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: Attempting download of new URL file:///C:/Azure/roles/[worker project]/approot/System.Runtime.Extensions.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

我在构建输出中看到的内容:

    2>  Task "Message"
2> CopyLocalDependencies=[solution]\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll
2> Task "Message"
2> CopyLocalDependencies=C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Facades\System.Runtime.Extensions.dll
...
2> Task "Message"
2> WorkerFiles=[solution]\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll -> System.Runtime.Extensions.dll
2> Task "Message"
2> WorkerFiles=C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Facades\System.Runtime.Extensions.dll -> System.Runtime.Extensions.dll
...
2> Copying file from "[solution]\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll" to "[solution]\[azure project]\obj\Debug\[worker project]\System.Runtime.Extensions.dll".
2> Copying file from "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Facades\System.Runtime.Extensions.dll" to "[solution]\[azure project]\obj\Debug\[worker project]\System.Runtime.Extensions.dll".

为什么 MSBuild 将 GAC 的程序集复制到本地文件夹?如何改变这种行为?我没有直接引用 GAC 的 System.Runtime.Extensions。或者如何更改复制程序集的顺序?

我尝试过的:

  1. 在工作器项目中添加属性 DoNotCopyLocalIfInGac = true
  2. 添加对 nuget 包 System.Runtime.Extensions 的直接引用

UPD发现类似问题

最佳答案

这是一个 MSBuild 14.0 错误。我发现了问题“ImplicitlyExpandDesignTimeFacades target should only add facades if a higher version isn't already referenced”。解决办法是修改the target ImplicitlyExpandDesignTimeFacades .

我做了什么:

  1. 使用修改后的 ImplicitlyExpandDesignTimeFacades 目标创建了一个单独的文件。
  2. 将其放在靠近工作线程的 csproj 文件的位置。
  3. 将此目标导入到工作线程的 csproj 文件中:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0"
DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
....
<Import Project="..\..\ImplicitlyExpandDesignTimeFacades.targets" />
</Project>

关于.net - nuget 的程序集被 GAC 的程序集覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43620108/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com