Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warn-as-error for MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved

Tags:

msbuild

After I have fixed this warning, how can I make it an error, so it doesn't slip in again?

msbuild /p:TreatWarningsAsErrors doesn't work

like image 515
Jay Bazuzi Avatar asked May 14 '14 18:05

Jay Bazuzi


3 Answers

You can use the generic mechanism MSBuildTreatWarningsAsErrors or <MSBuildWarningsAsErrors>MSB3277</MSBuildWarningsAsErrors> (introduced in #1928) to accomplish this.

  • credit: rainersigwald
like image 166
Andrew Arbogast Avatar answered Oct 19 '22 19:10

Andrew Arbogast


No happy answer to give you here. The TreatWarningsAsErrors property only affects the C# and VB.NET compiler (not C++), it determines the value of their /warnaserror command line option.

But MSB3277 is generated by an MSBuild task, ResolveAssemblyReference, its internal LogResult() method generates the diagnostic. The only property the class has that helps treat warnings as errors conditionally is WarnOrErrorOnTargetArchitectureMismatch, not what you are trying to achieve. You can have a look-see for yourself with a decompiler, look at C:\Program Files (x86)\MSBuild\12.0\Bin\Microsoft.Build.Tasks.v12.0.dll. The resource name for the localized MSB3277 message is "ResolveAssemblyReference.FoundConflicts".

So only way to get ahead here is to write a little utility that parses the log file and looks for the warning.

like image 43
Hans Passant Avatar answered Oct 19 '22 17:10

Hans Passant


Run Update-Package via Package Manager Console, this will fix MSB3277, what it does it reinstall all the packages and all related assemblies they come with to the highest version possible.

More info on official docs https://docs.microsoft.com/en-us/nuget/consume-packages/reinstalling-and-updating-packages

like image 21
Aistis Taraskevicius Avatar answered Oct 19 '22 17:10

Aistis Taraskevicius