Feature Request: Add System.Diagnostics.FileVersionInfo.GetVersionInfo() to "allow list" as Property Function
#3,457 opened on Jun 27, 2018
Description
Steps to reproduce
Project file
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Start">
<Message Text="$([System.DateTime]::Now.ToString('yyyy.MM.dd'))" />
<Message Text="$([System.Diagnostics.FileVersionInfo]::GetVersionInfo('C:\Windows\System32\notepad.exe').FileVersion)" />
</Target>
</Project>
Expected behavior
Run
Actual behavior
Build started 6/25/2018 7:20:06 PM. Project "C:\Test\test.proj" on node 1 (default targets). Start: 2018.06.25 C:\Test\test.proj(5,12): error MSB4212: Invalid static method invocation syntax: "[System.Diagnostics.FileVersionInfo]::GetVersionInfo('notepad.exe').FileVersion". The type "System.Dia gnostics.FileVersionInfo" is either not available for execution in an MSBuild property function or could not be found. Done Building Project "C:\Test\test.proj" (default targets) -- FAILED. Build FAILED.
Justification
My SDK is built in a strange way, in which, timestamp is not a reliable way to tracked incremental build nor updates. The solution is to either create a version.txt on disk that changes every run or get the version from an adjacent .dll or .exe. System.Diagnostics.FileVersionInfo offer such feature as a direct static call. It returns a string that represents the version.