[英]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.0
的Newtonsoft.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.