. net 3.5解决方案在使用msbuild编译时出现此警告。
有时NDepend可能会有所帮助,但在这种情况下,它没有提供任何进一步的细节。像Bob一样,我最终不得不在ILDASM中打开每个程序集,直到找到引用依赖程序集的旧版本。
我确实尝试使用VS 2010 Beta 2的MSBUILD(连接文章指出这在CLR的下一个版本中得到了修复),但也没有提供更多的细节(可能是在Beta 2后修复的)。
有没有更好的(更自动化的)方法?
. net 3.5解决方案在使用msbuild编译时出现此警告。
有时NDepend可能会有所帮助,但在这种情况下,它没有提供任何进一步的细节。像Bob一样,我最终不得不在ILDASM中打开每个程序集,直到找到引用依赖程序集的旧版本。
我确实尝试使用VS 2010 Beta 2的MSBUILD(连接文章指出这在CLR的下一个版本中得到了修复),但也没有提供更多的细节(可能是在Beta 2后修复的)。
有没有更好的(更自动化的)方法?
当前回答
Visual Studio for Mac Community新增:
由于AMissico的回答需要更改日志级别,而ASMSpy和ASMSpyPlus都不能作为跨平台解决方案,下面是Visual Studio for Mac的一个简短补充:
https://learn.microsoft.com/en-us/visualstudio/mac/compiling-and-building
它在Visual Studio社区→首选项…→项目→构建日志→冗长
其他回答
有时候@AMissico的答案是不够的。在我的例子中,我在Output窗口中找不到错误,所以我决定创建一个日志文件并分析它,执行以下步骤:
将构建日志保存到一个文件…https://msdn.microsoft.com/en-us/library/ms171470.aspx msbuild MyProject的。proj /fl /flp:logfile=MyProjectOutput.log 查找文本:警告MS…或者具体的警告信息:(例如,第9293行)发现不同版本之间存在冲突…和冲突错误的完整细节将在此消息的上面(例如,第9277行)。
Visual Studio 2013
我也犯了同样的错误,无法用其他答案来计算。我发现我们可以“巩固”NuGet包。
右键单击解决方案 单击“管理Nuget包” 合并选项卡并更新到相同的版本。
有时AutoGenerateBindingRedirects是不够的(即使有GenerateBindingRedirectsOutputType)。搜索所有There was a conflict条目并逐个手动修复它们可能很乏味,所以我写了一小段代码来解析日志输出并为您生成它们(转储到stdout):
// Paste all "there was a conflict" lines from the msbuild diagnostics log to the file below
const string conflictFile = @"C:\AssemblyConflicts.txt";
var sb = new StringBuilder();
var conflictLines = await File.ReadAllLinesAsync(conflictFile);
foreach (var line in conflictLines.Where(l => !String.IsNullOrWhiteSpace(l)))
{
Console.WriteLine("Processing line: {0}", line);
var lineComponents = line.Split('"');
if (lineComponents.Length < 2)
throw new FormatException("Unexpected conflict line component count");
var assemblySegment = lineComponents[1];
Console.WriteLine("Processing assembly segment: {0}", assemblySegment);
var assemblyComponents = assemblySegment
.Split(",")
.Select(kv => kv.Trim())
.Select(kv => kv.Split("=")
.Last())
.ToArray();
if (assemblyComponents.Length != 4)
throw new FormatException("Unexpected conflict segment component count");
var assembly = assemblyComponents[0];
var version = assemblyComponents[1];
var culture = assemblyComponents[2];
var publicKeyToken = assemblyComponents[3];
Console.WriteLine("Generating assebmly redirect for Assembly={0}, Version={1}, Culture={2}, PublicKeyToken={3}", assembly, version, culture, publicKeyToken);
sb.AppendLine($"<dependentAssembly><assemblyIdentity name=\"{assembly}\" publicKeyToken=\"{publicKeyToken}\" culture=\"{culture}\" /><bindingRedirect oldVersion=\"0.0.0.0-{version}\" newVersion=\"{version}\" /></dependentAssembly>");
}
Console.WriteLine("Generated assembly redirects:");
Console.WriteLine(sb);
提示:使用MSBuild二进制和结构化日志查看器,并仅为发出警告的项目中的冲突生成绑定重定向(也就是说,仅超过上述代码[AssemblyConflicts.txt]的输入文本文件的冲突行)。
如果您有resharper,删除解决方案中所有未使用的参考。
我也有这个问题,并使用了AMissico的建议,发现了这个问题(尽管必须将冗长级别设置为详细。
在找到罪魁祸首后,问题其实很简单。
背景: 我把我的项目从VS2008升级到VS2010。在VS2008中,目标框架是3.5,当我把它带入VS2010时,我把它切换到4 (Full)。我还升级了一些第三方组件,包括水晶报表。
结果发现大多数系统引用指向4.0.0.0版本,但有几个没有自动更改(System和System. web . services),仍然指向2.0.0.0版本。水晶报告引用4.0.0.0,所以这是冲突发生的地方。只需将光标放在解决方案资源管理器中的第一个System库上,向下移动列表并查找对2.0.0.0的任何引用,删除并重新添加新的4.0.0.0版本就可以了。
奇怪的是,大多数参考文献都被正确更新了,如果不是水晶报告,我可能永远都不会注意到……