In our “environment” we use quite complex .props
files and some custom targets. Among others one of the features is that project uses external libraries by importing a dedicated.props
file. If that library implies a dependency on its DLL file then the DLL file is added as custom item (ExternalFile
) that is later handled by custom target: it simply copies all such files to output directory. And this works
fine.
Among those external libraries is Qt with its complex DLL naming schema (which differs depending on version and configuration). We managed to deal with it with some property functions in those.props
files. And this works fine as well.
Now what doesn’t work are entries automatically added to .filters
file. It seems each time files are added to or removed from the project the.filters
file is modified as well. But not only by applying that single change but instead by looking for all items (including the once added by.props
files) and updating its own entries.
This results in items added “behind the scenes” in .props
files to show up in solution explorer while opened in Visual Studio. What is even worse is that even thou the files show up properly in Visual Studio solution explorer once added to.filters
file they are just “copied” without proper interpretation.
For example our QtCore.props
file will add item like that:
<ItemGroup><ExternalFile Include="$(QT_BIN)$([System.String]::Format('$(QT_NAME_PATTERN)', '$([System.Text.RegularExpressions.Regex]::Match('$(MSBuildThisFile)', '^Qt(.+)\.use\.props$').Groups[1].Value)')).dll" /></ItemGroup>
where QT_BIN
and QT_NAME_PATTERN
are properties defined elsewhere.
In Visual Studio solution explorer I can see under the project (properly)
Qt5Cored.dll
or QtCore4.dll
(depending on Qt version and configuration). While entry added to.filters
file is exactly the same. So the expression is not evaluated. (This happens as well when using just properties in the item name.)
This causes two issues. Firstly out of the .props
file context such entry no longer makes any sense since it uses$(MSBuildThisFile)
property. And secondly Visual Studio somehow doesn’t recognize it and will keep adding such entries over and over again even thou previously added once still exist.
As a side note I shall add that property edit dialog run from properties dialog in Visual Studio has similar issue. I mean the dialog which you may expand to show all properties known at the point. And properties with property functions are not evaluated there.
I’m using Visual Studio 2010.
Adam Badura