简体   繁体   English

重定向Nuget包DLL文件

[英]Redirect for Nuget Package DLL files

I would like to use the Nuget Package Microsoft.CodeAnalytics in the newest version 我想在最新版本中使用Nuget包Microsoft.CodeAnalytics
If I build the solution, there are issues regarding different versions of dlls that are part of the .NET framework 如果我构建解决方案,则存在有关.NET框架中不同版本的dll的问题

For example: 例如:

Zwischen "Reference:System.IO.FileSystem, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" und "Reference:System.IO.FileSystem" ist ein Konflikt aufgetreten. Zwischen“参考:System.IO.FileSystem,版本= 4.0.2.0,区域性=中性,PublicKeyToken = b03f5f7f11d50a3a,processorArchitecture = MSIL”和“参考:System.IO.FileSystem”,来自Konflikt aufgetreten。 "Reference:System.IO.FileSystem wird ausgewählt, da AssemblyVersion "4.0.3.0" höher ist als "4.0.2.0". (Aufgaben-ID: 19) “参考:System.IO.FileSystem,由AssemblyVersion” 4.0.3.0“和” 4.0.2.0“组成。(Aufgaben-ID:19)

The referenced assemblies can be found in downloaded Nuget packages that came with Microsoft.CodeAnalytics. 可以在Microsoft.CodeAnalytics随附的下载的Nuget程序包中找到引用的程序集。
The dlls are not copied locally when building. 生成时不会将dll复制到本地。 If I deploy the application like this, the program throws exceptions because it cannot find the referenced assemblies. 如果我这样部署应用程序,该程序将引发异常,因为它找不到所引用的程序集。

The solution would be to make the dlls look for the newest version but I don't know how to do that. 解决方案是使dll查找最新版本,但我不知道该怎么做。
In the app.config the redirect is written down. 在app.config中,重定向被记录下来。

<assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />

If I try to run the application like this, it still throws errors because it cannot find the .dll in version 4.0.2.0 when calling classes of the CodeAnalytics-package. 如果我尝试以这种方式运行该应用程序,它仍然会引发错误,因为在调用CodeAnalytics-package的类时无法在4.0.2.0版中找到.dll。

How do I get Visual Studio/msbuild to copy the files locally even if there are file versions higher in .NET Framework or how do I get the dll to look for the correct version of the other dll? 即使.NET Framework中有更高版本的文件,如何获取Visual Studio / msbuild以在本地复制文件?如何获取dll以查找其他dll的正确版本?

You can force the dlls to be included by: In the Solution Explorer, under References the project in which CodeAnalysis is included, right click on the dll, select Properties, in Properties window, change 'Copy Local' to true. 您可以通过以下方式强制包含这些dll:在“解决方案资源管理器”中,在“引用”下包含CodeAnalysis的项目下,右键单击该dll,选择“属性”,在“属性”窗口中,将“复制本地”更改为true。

What happens when you change the app.config by removing the bindingRedirect element? 通过删除bindingRedirect元素更改app.config会发生什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM