How to count how many times an imported MS-Build property was referenced (read) by a project ?
For example one of the files imported by the MS-Build Project defines a sensitive property $(CipherNonce) like this:
</Project>
<PropertyGroup>
<CipherNonce>314159</CipherNonce>
</PropertyGroup>
</Project>
I would like to determine how many times the $(CipherNonce) property was read/used (referenced) by this MS-Build Project, which also imports dozens of .targets files.
At the moment I am using the -preprocess[:filepath] option to generate a single, aggregated project file, which I am searching for references to $(CipherNonce) with a regex - but that is such a hack and it misses the references to this property, which are made by the VS IDE.
MSBuild currently doesn't track all property reads (just unassigned property reads and env var reads). That being said - if you'd need to track all property reads, you'd need to build your version of MSBuild and hook the read yourself (here)