[System.Diagnostics.FileVersionInfo]::GetVersionInfo("$Path").FileVersion
not working (as expected).
#88837
-
Per microsoft/winget-pkgs#112057 (comment)
Am I using this incorrectly?
works, so it's not like the functionality isn't present... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
As far as I can tell, the problem is that PowerShell current directory ( One way that works for me is to use the absolute path of the file: > [System.Diagnostics.FileVersionInfo]::GetVersionInfo((gci "$OutFile").FullName).FileVersion
1.0.0.0 Though I don't know PowerShell that well, so there may be a better way to do this. |
Beta Was this translation helpful? Give feedback.
As far as I can tell, the problem is that PowerShell current directory (
pwd
) is not the same as .Net current directory ([System.IO.Directory]::GetCurrentDirectory()
). And the .Net classFileVersionInfo
expects the path relative to the .Net current directory, which is why it can't find the file.One way that works for me is to use the absolute path of the file:
Though I don't know PowerShell that well, so there may be a better way to do this.