Microsoft.Extensions.Logging.Abstractions: System.IO.FileNotFoundException only on build server version

huangapple go评论57阅读模式
英文:

Microsoft.Extensions.Logging.Abstractions: System.IO.FileNotFoundException only on build server version

问题

我收到一个错误消息,说找不到一个文件。如果我在本地编译程序,它可以运行。
只有在构建服务器上编译的版本在本地运行时失败。

未处理的异常: System.IO.FileNotFoundException: 无法加载文件或程序集 'Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'。系统找不到指定的文件。
文件名: 'Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
在 Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.g__BuildServiceProvider|4_1(IDbContextOptions _, ValueTuple2 arguments) 在 Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.<>c.<GetOrAdd>b__4_0(IDbContextOptions contextOptions, ValueTuple2 tuples)
在 System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd[TArg](TKey key, Func3 valueFactory, TArg factoryArgument)
在 Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.GetOrAdd(IDbContextOptions options, Boolean providerRequired)
在 Microsoft.EntityFrameworkCore.DbContext..ctor(DbContextOptions options)
在 Microsoft.EntityFrameworkCore.DbContext..ctor()
在 MyProject.Models.DbContext..ctor() 在 c:\path\to\ci\pipeline\MyProject\Models\DbContext.cs:line 12

如果重要的话:Microsoft.EntityFrameworkCore被解决方案中的多个项目使用。
这是否与CopyLocal属性有关?

编辑:
我现在在另一个地方找到了问题:某个NuGet包使用了版本为2.0.0的Microsoft.Extensions.Logging.Abstractions。确切的包未知,但似乎该版本已添加到输出中。奇怪的是,Visual Studio没有显示任何NuGet冲突。

英文:

I get an error that says a file was not found. If I compile the program locally, it works.<br>Only the version compiled on the build server fails when run locally.

Unhandled exception: System.IO.FileNotFoundException: Could not load file or assembly &#39;Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60&#39;. The system cannot find the file specified.
File name: &#39;Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60&#39;
   at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.&lt;GetOrAdd&gt;g__BuildServiceProvider|4_1(IDbContextOptions _, ValueTuple`2 arguments)
   at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.&lt;&gt;c.&lt;GetOrAdd&gt;b__4_0(IDbContextOptions contextOptions, ValueTuple`2 tuples)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd[TArg](TKey key, Func`3 valueFactory, TArg factoryArgument)
   at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.GetOrAdd(IDbContextOptions options, Boolean providerRequired)
   at Microsoft.EntityFrameworkCore.DbContext..ctor(DbContextOptions options)
   at Microsoft.EntityFrameworkCore.DbContext..ctor()
   at MyProject.Models.DbContext..ctor() in c:\path\to\ci\pipeline\MyProject\Models\DbContext.cs:line 12

If it is important: The Microsoft.EntityFrameworkCore is used by several projects in the solution.<br>
Can this have something to do with the CopyLocal property?

EDIT:
I have now identified the problem in another place: Some nuget package uses Microsoft.Extensions.Logging.Abstractions in version 2.0.0. Which one it is exactly is not known, but it seems that this version is added to the output. Strangely, Visual Studio does not show any Nuget conflicts.

答案1

得分: 1

经过一些搜索,我终于找到了问题。一个旧的Windows Forms应用似乎对Microsoft.Extensions.Logging.Abstractions有隐式依赖。在Obj文件夹中,你可以看到对2.0.0版本的依赖。构建服务器按顺序编译解决方案中的所有项目,所以2.0.0版本总是最后出现在bin文件夹中,覆盖了7.0.0版本。本地行为可能因并行编译而不同。<br><br>
解决方案:
更改Windows Forms应用程序的输出路径,而不是将所有内容编译到一个文件夹中。

英文:

After some searching I finally found the problem. An old Windows Forms app seems to have an implicit dependency on Microsoft.Extensions.Logging.Abstractions. In the Obj folder you could see a dependency on version 2.0.0. The build server compiles all projects in the solution sequentially, so the 2.0.0 version always ended up last in the bin folder, overwriting the 7.0.0. Locally the behavior is probably different due to parallel compilation.<br><br>
Solution:
Change the output path for the Windows Forms app and not compile everything into one folder.

huangapple
  • 本文由 发表于 2023年7月10日 18:16:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76652771.html
  • .net
  • c#
  • deployment
  • entity-framework
  • entity-framework-core
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定