The Environment.OSVersion property does not provide a reliable way to identify the exact operating system and its version. Therefore, we do not recommend that you use this method. Instead:
To identify the operating system platform, use the RuntimeInformation.IsOSPlatform method.
Avoid writing code that depends on a reported operating system version. Instead, check for the availability of the features that your application needs.
When building we are getting the error Environment.OSVersion.get is deprecated
The following stackoverflow post https://stackoverflow.com/questions/55193222/environment-osversion-get-is-deprecated
says it is not recommended to use this method.
The Environment.OSVersion property does not provide a reliable way to identify the exact operating system and its version. Therefore, we do not recommend that you use this method. Instead:
To identify the operating system platform, use the RuntimeInformation.IsOSPlatform method.
Avoid writing code that depends on a reported operating system version. Instead, check for the availability of the features that your application needs.