了解 "Found conflicts between different versions of " Microsoft.WindowsAzure.Storage " that could not



VisualStudio 2017(15.5.4)的构建日志让我对如何摆脱警告感到困惑

发现无法解决的不同版本的"Microsoft.WindowsAzure.Storage"之间的冲突。 当日志详细程度设置为详细时,这些引用冲突将列在生成日志中。 Animals.Swine.Functions C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets

There was a conflict between "Microsoft.WindowsAzure.Storage, Version=7.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" and "Microsoft.WindowsAzure.Storage, Version=8.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35".
"Microsoft.WindowsAzure.Storage, Version=7.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" was chosen because it was primary and "Microsoft.WindowsAzure.Storage, Version=8.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" was not.
References which depend on "Microsoft.WindowsAzure.Storage, Version=7.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" [D:ReposAnimalssrcAnimals.SwinepackagesWindowsAzure.Storage.7.2.1libnet40Microsoft.WindowsAzure.Storage.dll].
D:ReposAnimalssrcAnimals.SwinepackagesWindowsAzure.Storage.7.2.1libnet40Microsoft.WindowsAzure.Storage.dll
Project file item includes which caused reference "D:ReposAnimalssrcAnimals.SwinepackagesWindowsAzure.Storage.7.2.1libnet40Microsoft.WindowsAzure.Storage.dll".
Microsoft.WindowsAzure.Storage, Version=7.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
References which depend on "Microsoft.WindowsAzure.Storage, Version=8.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" [].
D:ReposAnimalssrcAnimals.CommonAnimals.Common.FunctionsbinDebugnet461binAnimals.Common.Functions.dll
Project file item includes which caused reference "D:ReposAnimalssrcAnimals.CommonAnimals.Common.FunctionsbinDebugnet461binAnimals.Common.Functions.dll".
D:ReposAnimalssrcAnimals.CommonAnimals.Common.FunctionsbinDebugnet461binAnimals.Common.Functions.dll
D:ReposAnimalssrcpackagesMicrosoft.Azure.WebJobs.2.1.0libnet45Microsoft.Azure.WebJobs.Host.dll
Project file item includes which caused reference "D:ReposAnimalssrcpackagesMicrosoft.Azure.WebJobs.2.1.0libnet45Microsoft.Azure.WebJobs.Host.dll".
Microsoft.Azure.WebJobs.Host, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.Azure.WebJobs.Extensions, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL
D:ReposAnimalssrcAnimals.CommonAnimals.CommonbinDebugnet45Animals.Common.dll
Project file item includes which caused reference "D:ReposAnimalssrcAnimals.CommonAnimals.CommonbinDebugnet45Animals.Common.dll".
D:ReposAnimalssrcAnimals.SwineAnimals.SwinebinDebugAnimals.Swine.dll
D:ReposAnimalssrcAnimals.CommonAnimals.CommonbinDebugnet45Animals.Common.dll
D:ReposAnimalssrcAnimals.SwinepackagesMicrosoft.Azure.WebJobs.Extensions.2.0.0libnet45Microsoft.Azure.WebJobs.Extensions.dll
Project file item includes which caused reference "D:ReposAnimalssrcAnimals.SwinepackagesMicrosoft.Azure.WebJobs.Extensions.2.0.0libnet45Microsoft.Azure.WebJobs.Extensions.dll".
Microsoft.Azure.WebJobs.Extensions, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL

如果我们浏览据报道使用 Storage 8.1.1.0 的引用,我们会看到第一个、第三个和最后一个引用本身。为什么这么想?这甚至意味着什么?

D:ReposAnimalssrcAnimals.CommonAnimals.Common.FunctionsbinDebugnet461binAnimals.Common.Functions.dll
Project file item includes which caused reference "D:ReposAnimalssrcAnimals.CommonAnimals.Common.FunctionsbinDebugnet461binAnimals.Common.Functions.dll".
D:ReposAnimalssrcAnimals.CommonAnimals.Common.FunctionsbinDebugnet461binAnimals.Common.Functions.dll
...
D:ReposAnimalssrcAnimals.CommonAnimals.CommonbinDebugnet45Animals.Common.dll
Project file item includes which caused reference "D:ReposAnimalssrcAnimals.CommonAnimals.CommonbinDebugnet45Animals.Common.dll".
D:ReposAnimalssrcAnimals.SwineAnimals.SwinebinDebugAnimals.Swine.dll
D:ReposAnimalssrcAnimals.CommonAnimals.CommonbinDebugnet45Animals.Common.dll
D:ReposAnimalssrcAnimals.SwinepackagesMicrosoft.Azure.WebJobs.Extensions.2.0.0libnet45Microsoft.Azure.WebJobs.Extensions.dll
Project file item includes which caused reference "D:ReposAnimalssrcAnimals.SwinepackagesMicrosoft.Azure.WebJobs.Extensions.2.0.0libnet45Microsoft.Azure.WebJobs.Extensions.dll".
Microsoft.Azure.WebJobs.Extensions, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL

第二个似乎是检查和讨论的更好地方:

D:ReposAnimalssrcpackagesMicrosoft.Azure.WebJobs.2.1.0libnet45Microsoft.Azure.WebJobs.Host.dll
Project file item includes which caused reference "D:ReposAnimalssrcpackagesMicrosoft.Azure.WebJobs.2.1.0libnet45Microsoft.Azure.WebJobs.Host.dll".
Microsoft.Azure.WebJobs.Host, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.Azure.WebJobs.Extensions, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL

因此,如果我没看错,Microsoft.Azure.WebJobs.Host, Version=2.1.0.0Microsoft.Azure.WebJobs.Extensions, Version=2.0.0.0都应该引用Microsoft.WindowsAzure.Storage, Version=8.1.1.0。但是,如果我们查看Nuget依赖项,WebJobs引用7.2.1.0,WebJobs.Extensions仅引用回[WebJobs]。

我没有看到任何引用8.1.1.0!存储没有被任何项目直接引用,我没有看到间接引用。

我已经在"D:\Repos\Animals\src\Animals.Swine\Animals.Swine.Functions\bin\"上运行了AsmSpy,但它甚至没有显示存储冲突。

如何确定存储 8.1.1.0 引用的来源?

更新:我进行了文本搜索,发现设置了绑定重定向,"8.1.1.0"作为新版本。我将其更改为"7.2.1.0",警告消失了。即使认为警告已经消失,我仍然将问题保持开放状态,以便有人可以深入了解如何阅读构建日志以及日志如何为我们指明正确的方向。

如何确定存储 8.1.1.0 引用的来源?

构建日志可以帮助我们解决大多数问题,但不能解决所有问题。它仍然需要我们手动解决这些问题。因为Visual Studio/MSBuild无法智能地直接找到问题的根本原因。

当我们遇到此 MSB3247/MSB3277 错误时,解决此问题的最佳方法是将 MSBuild 输出日志转到诊断(工具->选项->项目和解决方案->生成并运行,设置 MSBuild 项目生成输出详细程度),然后查找依赖于Microsoft.WindowsAzure.Storage的引用,检查是否有不同版本的Microsoft.WindowsAzure.Storage被引用。

在构建日志中,我们发现项目文件项包括导致引用Microsoft.Azure.WebJobs.2.1.0Microsoft.Azure.WebJobs.Extensions.2.0.0

然后检查这两个包的依赖关系,它们都没有引用Microsoft.WindowsAzure.Storage, Version=8.1.1.0

为了确认,您可以使用弗拉基米尔在评论中提供的方法。

此时此刻,这种冲突不应该来自参考资料。然后我们应该检查与引用版本相关的文件,例如app.config或web.config,找到关于引用Microsoft.WindowsAzure.Storage的绑定重定向,检查绑定重定向是否正确。

所以有时候我们不能仅仅根据构建日志信息直接解决问题,手动排查也是必不可少的。

相关内容

最新更新