简体   繁体   English

使用MSBuild时,Visual Studio Android解决方案在遇到C#版本冲突时停止构建

[英]Visual Studio Android solution stops building upon hitting C# version conflict when using MSBuild

The solution builds fine in Visual Studio 2017. 该解决方案在Visual Studio 2017中构建良好。

MSBuild will produce the following warning: MSBuild将产生以下警告:

C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\MSBuild\\15.0\\Bin\\Microsoft.Common.CurrentVersion.targets (2106, 5): warning MSB3277: Found conflicts between different versions of "Microsoft.CSharp" that could not be resolved. C:\\ Program Files(x86)\\ Microsoft Visual Studio \\ 2017 \\ Professional \\ MSBuild \\ 15.0 \\ Bin \\ Microsoft.Common.CurrentVersion.targets(2106,5):警告MSB3277:在不同版本的“ Microsoft.CSharp”之间发现冲突无法解决。 These reference conflicts are listed in the build log when log verbosity is set to detailed. 将日志详细程度设置为“详细”时,这些参考冲突会在构建日志中列出。

A couple line will show up after the warning, but from there it halts and doesn't progress at all. 警告后会出现几行,但从那里停下来,根本没有进展。

The actual reference conflict is here: 实际的参考冲突在这里:

There was a conflict between "Microsoft.CSharp, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". 在“ Microsoft.CSharp,版本= 2.0.5.0,文化=中性,PublicKeyToken = b03f5f7f11d50a3a”和“ Microsoft.CSharp,版本= 4.0.0.0,文化=中性,PublicKeyToken = b03f5f7f11d50a3a”之间存在冲突。 (TaskId:123) 4> "Microsoft.CSharp, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not. (TaskId:123)4>选择“ Microsoft.CSharp,版本= 2.0.5.0,文化=中性,PublicKeyToken = b03f5f7f11d50a3a”,因为它是主要的,并且选择了“ Microsoft.CSharp,版本= 4.0.0.0,文化=中性,PublicKeyToken = b03f5f7f11d50a3a”不是。 (TaskId:123) 4> References which depend on "Microsoft.CSharp, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\Common7\\IDE\\ReferenceAssemblies\\Microsoft\\Framework\\MonoAndroid\\v1.0\\Microsoft.CSharp.dll]. (TaskId:123)4>引用取决于“ Microsoft.CSharp,版本= 2.0.5.0,区域性=中性,PublicKeyToken = b03f5f7f11d50a3a” [C:\\ Program Files(x86)\\ Microsoft Visual Studio \\ 2017 \\ Professional \\ Common7 \\ IDE \\ ReferenceAssemblies \\微软\\框架\\ MonoAndroid \\ 1.0 \\ Microsoft.CSharp.dll。 (TaskId:123) 4> C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\Common7\\IDE\\ReferenceAssemblies\\Microsoft\\Framework\\MonoAndroid\\v1.0\\Microsoft.CSharp.dll (TaskId:123) 4> Project file item includes which caused reference "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\Common7\\IDE\\ReferenceAssemblies\\Microsoft\\Framework\\MonoAndroid\\v1.0\\Microsoft.CSharp.dll". (TaskId:123)4> C:\\ Program Files(x86)\\ Microsoft Visual Studio \\ 2017 \\ Professional \\ Common7 \\ IDE \\ ReferenceAssemblies \\ Microsoft \\ Framework \\ MonoAndroid \\ v1.0 \\ Microsoft.CSharp.dll(TaskId:123) 4>项目文件项包括引起引用的“ C:\\ Program Files(x86)\\ Microsoft Visual Studio \\ 2017 \\ Professional \\ Common7 \\ IDE \\ ReferenceAssemblies \\ Microsoft \\ Framework \\ MonoAndroid \\ v1.0 \\ Microsoft.CSharp.dll”。 (TaskId:123) 4> Microsoft.CSharp (TaskId:123) 4> References which depend on "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" []. (TaskId:123)4> Microsoft.CSharp(TaskId:123)4>依赖于“ Microsoft.CSharp,版本= 4.0.0.0,区域性=中性,PublicKeyToken = b03f5f7f11d50a3a” []的引用。 (TaskId:123) 4> C:\\Users\\laniganr.nuget\\packages\\newtonsoft.json\\10.0.3\\lib\\netstandard1.3\\Newtonsoft.Json.dll (TaskId:123) (任务编号:123)4> C:\\ Users \\ laniganr.nuget \\ packages \\ newtonsoft.json \\ 10.0.3 \\ lib \\ netstandard1.3 \\ Newtonsoft.Json.dll(任务编号:123)

A couple other lines will show up right after the error, but never progresses past this point. 错误发生后,还会显示其他几行,但从此以后就不会继续进行。

Said lines: 说行:

_XamarinAndroidBuildAarRestore: Reference has already had resources merged, skipping due to: obj\\ReleaseNuget\\XbdMerge\\Xamarin.GooglePlayServices.Bas ement.dll.stamp Reference has already had resources merged, skipping due to: obj\\ReleaseNuget\\XbdMerge\\Xamarin.GooglePlayServices.Tas ks.dll.stamp Reference has already had resources merged, skipping due to: obj\\ReleaseNuget\\XbdMerge\\Xamarin.Firebase.Common.dll.st amp Reference has already had resources merged, skipping due to: obj\\ReleaseNuget\\XbdMerge\\Xamarin.Firebase.Iid.dll.stamp Reference has already had resources merged, skipping due to: obj\\ReleaseNuget\\XbdMerge\\Xamarin.Firebase.Messaging.dll .stamp _ResolveLibraryProjectImports: Skipping target "_ResolveLibraryProjectImports" because all output files are up-to-date with respect to the input files . _XamarinAndroidBuildAarRestore:参考已经合并了资源,由于以下原因而跳过:obj \\ ReleaseNuget \\ XbdMerge \\ Xamarin.GooglePlayServices.Bas ement.dll.stamp参考已经合并了资源,由于以下原因而跳过:obj \\ ReleaseNuget \\ XbdMerge \\ Xamarin.GooglePlayServices。 Tas ks.dll.stamp参考已经合并了资源,由于以下原因而被跳过:obj \\ ReleaseNuget \\ XbdMerge \\ Xamarin.Firebase.Common.dll.st amp参考已经被合并了资源,由于以下原因而被跳过:obj \\ ReleaseNuget \\ XbdMerge \\ Xamarin.Firebase.Iid.dll.stamp参考已经合并了资源,由于以下原因而被跳过:obj \\ ReleaseNuget \\ XbdMerge \\ Xamarin.Firebase.Messaging.dll .stamp _ResolveLibraryProjectImports:跳过目标“ _ResolveLibraryProjectImports”,因为所有输出文件都是最新的输入文件的日期。 _BuildLibraryImportsCache: Skipping target "_BuildLibraryImportsCache" because all output files are up-to-date with respect to the input files. _BuildLibraryImportsCache:跳过目标“ _BuildLibraryImportsCache”,因为所有输出文件都相对于输入文件而言是最新的。

Visual Studio Android solution stops building upon hitting C# version conflict when using MSBuild 使用MSBuild时,Visual Studio Android解决方案在遇到C#版本冲突时停止构建

That because there is an explicit reference to Microsoft.CSharp 2.0.5.0 in the Xamarin.Android project when there is a reference to Microsoft.CSharp 4.3.0.0 in the netstandard library project from a library newtonsoft.json 10.0.3 . 那是因为当从库newtonsoft.json 10.0.3引用netstandard库项目中的Microsoft.CSharp 4.3.0.0时,在Xamarin.Android项目中明确引用了Microsoft.CSharp 2.0.5.0

In the build log, you can find your project referencing the package newtonsoft.json in following message: 在构建日志中,可以在以下消息中找到引用包newtonsoft.json项目:

C:\\Users\\xxxxx\\packages\\newtonsoft.json\\10.0.3\\lib\\netstandard1.3\\Newtonsoft.Json.dll (TaskId:123) C:\\ Users \\ xxxxx \\ packages \\ newtonsoft.json \\ 10.0.3 \\ lib \\ netstandard1.3 \\ Newtonsoft.Json.dll(TaskId:123)

Then check the dependence of the package newtonsoft.json\\10.0.3\\lib\\netstandard1.3 : 然后检查软件包newtonsoft.json\\10.0.3\\lib\\netstandard1.3的依赖关系:

在此处输入图片说明

To resolve this issue, you can try to update Newtonsoft.Json to the version 11.0.1 and above. 要解决此问题,您可以尝试将Newtonsoft.Json更新到版本11.0.1及更高版本。 This is because this version of Newtonsoft.Json package for netstandard 2.0 has no dependency to Microsoft.CSharp . 这是因为此版本的netstandard 2.0Newtonsoft.Json程序包不依赖于Microsoft.CSharp

Alternatively, you can remove the Microsoft.CSharp 2.0.5 and allow the one from Nuget to be used. 或者,您可以删除Microsoft.CSharp 2.0.5并允许使用Nuget中的一个。

You can refer to the similar thread here and here for some more details. 您可以在此处此处引用类似的线程以获取更多详细信息。

Hope this helps. 希望这可以帮助。

暂无
暂无

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

相关问题 使用msbuild构建时出现C#版本错误,使用Visual Studio可以 - C# version error when building with msbuild, ok with Visual Studio 使用C#代码中的msbuild构建Visual Studio解决方案 - Build visual studio solution using msbuild from c# code 使用 c#、visual studio 和 msbuild 编辑解决方案 - editing a solution with c#, visual studio and msbuild 使用 MSBuild.exe 在发布模式下构建 C# 解决方案 - Building C# Solution in Release mode using MSBuild.exe 从 Visual Studio 2019 中的 C# 解决方案返回 cmake 项目时,Resharper 智能感知停止工作 - when going back to cmake project from C# solution in visual studio 2019 Resharper intellisense stops working 针对C#解决方案的MSBuild(类似版本)上的自定义 - Customizations on MSBuild (like version) for a C# solution 在 Visual Studio 中构建 C# 应用程序时,如何在可执行文件名中嵌入版本信息? - How to embed the version information in the executable file name when building C# application in Visual Studio? Visual Studio:构建解决方案时输出时间戳 - Visual Studio: Output a timestamp when building solution 使用 MSBuild 时加载的 nuget 包与使用 Visual Studio 构建时加载的不同 - Different nuget-packages loaded when using MSBuild than building using Visual Studio 需要在命令行上使用较低版本的msbuild C#项目,而无需Visual Studio - Need to msbuild C# project of lower version on commandline, without Visual Studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM