0

I use property sheets to manage inclusion of header and library dependencies. In the dependency tree, a project might end up including a property sheet twice, if 2 dependencies share a common dependency (and that's because property sheets can include other propery sheets).

Which results in:

warning MSB4011: "xxx.props" ne peut pas être réimporté car il a déjà été importé. Cette importation est ignorée. (already imported, ignored....)

This is just a warning but I would like to disable it. How ?

I tried compiler option:

/nowarn:MSB4011

/nowarn:4011

Doesn't work.

I tried pragma:

#pragma warning( disable : 4011)

Doesn't work.

PinkTurtle
  • 6,942
  • 3
  • 25
  • 44
  • Don't have msbuild in this tablet ... but are you sure the option is spelled "norwarn" not something like "nowarn"? – Öö Tiib Apr 13 '22 at 17:05
  • I know that there is the `/wd` option. That's what my projects are using. For example `/wd"4011"` But that's the C++ compiler. – Joe Apr 13 '22 at 17:08
  • @ÖöTiib good catch. That said it still has no effect with `nowarn` – PinkTurtle Apr 13 '22 at 17:19
  • @Joe i'm using msvc; I tried `/wd"4011"` which seems the correct way to do this, but has no effect. The warning id is `MSB4011` and if I try `/wd"MSB4011"` I get "numeric argument not valid". I think MSB stands for "microsoft build", it's not a C++ warning even tho I'm compiling c++ code. – PinkTurtle Apr 13 '22 at 17:26
  • Just to be sure, go to the property page of the actual *project* being built to be sure that the property sheet settings are actually getting there. It's possible that you can set a setting in a property sheet and then the project that includes it just completely overrides the setting. So go to the project (not the sheet), right click and choose "Properties". The under C++, look at the "Command line" setting and be sure that you truly see your option in there. If not, got to "Advanced" (again under C++) and look at "Disable Specific Warnings" – Joe Apr 13 '22 at 17:30
  • Just did that and disabled warning 4011 and it has no effect. The issue is that `4011 != MSB4011`. It's not a C++ warning it's a MSBuild warning (it's tied to the visual studio IDE). I think I just can't remove this warning. – PinkTurtle Apr 13 '22 at 18:14
  • Is this [thread](https://stackoverflow.com/a/63724725/16764520) useful? – Minxin Yu - MSFT Apr 14 '22 at 05:47
  • @MinxinYu-MSFT didn't help unfortunately :( – PinkTurtle Apr 15 '22 at 08:34

2 Answers2

0

Suppressing the warning level with /p:WarningLevel=X might be a way, other than that, there doesn't seem to be a way: related thread. I suggest to propose a new feature (suppress MSB warning) to Developer Community. You can put the link in the comments.

Minxin Yu - MSFT
  • 2,234
  • 1
  • 3
  • 14
0

How about good old Include-Guard?
In the importing Projects:

<Import Project="my_global_defs.props"
        Condition="'$(MyGlobalDefs_Version)'==''" />

and in the imported Project:

<PropertyGroup Label="IncludeGuard" >
  <MyGlobalDefs_Version>1.0</MyGlobalDefs_Version>
</PropertyGroup>

:´( OK, the importer must know the name of the include-guard.
But it works.