Asked by:
Turning off msbuild warnings (MSB3305)

Question
-
Hi there -
is there ANY way to turn off msbuild warnings (e.g. MSB3305)?
09:50:17.900 29>C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(2234,5): warning MSB3305: Processing COM reference "" from path "C:\Windows\System32\stdole2.tlb". The type library importer could not convert the signature for the member 'DISPPARAMS.rgvarg'. [C:\Builds\1\BINARY\Tool_CI\src\Tool\Apps\Platform\Platform.csproj]
We'd like to establish a 0 warnings policy for our project - and not set the warning level to 0 - but cannot get rid of the mentioned warning on our build server.
Any suggestions much appreciated!
Thanks,
Jay- Edited by Jay Mc Bee Friday, October 31, 2014 9:34 AM
Friday, October 31, 2014 9:31 AM
All replies
-
Hi Jay,
I see that you don't want to set the warning level to 0 to turn off emission of all warning messages. But, if you want to disable the warnings except for changing the warning level to 0, the best way is to fix the issues that are causing the warnings.
Best regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.Monday, November 3, 2014 7:46 AM -
Although in general, fixing the underlying problem is the best way to fix warnings, that's not possible when the underlying 'problem' is that the Microsoft-supplied build tooling dislikes something about a Microsoft-supplied library. Unless you happen to be Microsoft, you're not in a position to change either of the parts that are causing the problem.
The 'stdole2.tlb' type library is part of Windows, so Jay can't change that. And it appears that any attempt to reference that type library from a C# project causes MSBuild to produce this warning. Jay can't change MSBuild either.
So if you want to use both 'stdole2.tlb' and MSBuild, the only remaining option would be to tell it not to generate the warnings. Except it's not obvious that there's a way to do that.
The difficulty here is that the 'problem' that MSBuild is identifying here isn't truly a problem at all. It's just telling us that the imported library contains some features which, if you chose to use them, would be problematic in a .NET world. Unfortunately, it generates those warnings even if your code doesn't use any of those problematic bits. This is perfectly normal when importing type libraries that weren't designed with .NET in mind. And as long as your C# code never attempts to use those features you'll be fine. Since the warning is in effect reporting a problem where there is no problem, it doesn't look like you can 'fix the issues that are causing the warnings' here because there isn't an issue to fix.
If there were some way to selectively import only the parts you want to use, this wouldn't be a problem. But you can't - you either import the whole library or you don't use it at all. I'm having exactly the same problem with MSTSCLib, the (Microsoft-supplied) COM library for working with remote desktop and terminal services.
The warning may be useful as a way to highlight areas of the TLB to avoid when you first add it to your project, but this feature really needs some way of saying "Yes, I know, and I'll avoid those parts."
Saturday, December 20, 2014 8:18 AM -
I've found a way to stop the warnings from appearing, but I'm not sure how reliable it is, because it uses a feature for which the I've not found any direct documentation, and the only related thing I've found carries this warning: "This API supports the .NET Framework infrastructure and is not intended to be used directly from your code."
I've added this in the PropertyGroup at the top of my .csproj file:
<ResolveComReferenceSilent>True</ResolveComReferenceSilent>
I've not been able to find this documented directly, but looking at the targets files in the SDK, you can see that this affects the following property: http://msdn.microsoft.com/en-us/library/microsoft.build.tasks.resolvecomreference.silent(v=vs.110).aspx but that's the one with the warning that this is for internal use.
That said, I'm not using the unsupported setting directly: I'm using it via this property. And although I've not found any docs for the property itself, there is at least one page that tells you about the property. Although it's for a quite different kind of project, http://msdn.microsoft.com/en-us/library/windows/hardware/jj659905(v=vs.85).aspx does recommend using this to remove spurious warnings from a COM reference.
- Proposed as answer by ervinc Thursday, June 4, 2015 12:19 AM
Saturday, December 20, 2014 8:30 AM -
Thanks, great tip! I've been looking for such a workaround, but have not seen it mentioned before.Tuesday, May 12, 2015 9:22 AM