0

Specifically, I have a problem with MSB3026 - Could not copy bla-bla-bla to bla-bla-bla. Beginning retry 1 in 1000ms. The process cannot access the file bla-bla-bla because it is being used by another process.

I know why it happens - two different libraries use two different versions of the same dependency, but I cannot fix that right now.

So, I want to tell MSBuild to treat all the warnings, except MSB3026, as errors.

I do not understand if this is possible. Is it?

mark
  • 59,016
  • 79
  • 296
  • 580
  • According to the documentation for warnaserror you can pass it a list of warnings, is that what you are looking for? Else there's e.g. https://stackoverflow.com/questions/17495278/how-can-i-treat-msb3245-could-not-resolve-reference-warning-as-an-error – stijn Nov 19 '18 at 19:35
  • Nope, I want all the warnings to be treated as errors, except MSB3026. But I think I have the answer here - https://github.com/Microsoft/msbuild/issues/3062#issuecomment-439945441 – mark Nov 19 '18 at 19:51

1 Answers1

0

The answer was provided here - https://github.com/Microsoft/msbuild/issues/3062#issuecomment-439945441 by Rainer Sigwald.

There is the flag /warnasmessage which demotes warnings to simple messages. It has higher priority than /warnaserror, so it is good enough.

To fail on all the warnings, except MSB3026 one would pass this to msbuild /err /nowarn:MSB3026

mark
  • 59,016
  • 79
  • 296
  • 580
  • Did you use warnAsMessage in the end? `/nowarn:MSB3026` (or specifically, `/p:NoWarn=AD0001%2CMSB3026`) doesn't seem to fix this. – Piedone Jan 24 '21 at 21:09
  • Yes. It works. What is `AD0001%2CMSB3026` ? I assume you wish to suppress both AD0001 and MSB3026. `/p:NoWarn` is **not** the same as `/nowarn`. So, try `/nowarn` – mark Jan 24 '21 at 22:56
  • Yes, that would be a suppress for two error codes. Ah I see, that's very valuable, thank you! – Piedone Jan 25 '21 at 14:40