The following property definition reads a value from a registry key:
<PropertyGroup>
<MyProperty>$(HKEY_LOCAL_MACHINE\MyKey\My@ValueName</MyProperty>
</PropertyGroup>
In this example, ValueName represents the value in the \HKEY_LOCAL_MACHINE\MyKey\My\ registry key. To read the default value, reference \HKEY_LOCAL_MACHINE\MyKey\My\ without specifying <ValueName>. For example:
<PropertyGroup>
<MyProperty>$(HKEY_LOCAL_MACHINE\MyKey\My</MyProperty>
</PropertyGroup>
Note: |
|---|
| If you try to read the registry key and you do not have the required user rights, an access violation may occur and you may receive an error that is similar to the following. MSBUILD: Configuration error MSB4146: Cannot evaluate the property expression "..\WinFx\v3.5$(registry:HKEY_LOCAL_MACHINE\software\x)" found at "c:\ToolPlat\src\tools\x86\managed\v2.0\MSBuild.exe.config, line 15". The expression "$(registry:HKEY_LOCAL_MACHINE\software\x)" cannot be evaluated. Requested registry access is not allowed. A similar error occurs if the expression is in a project rather than the config file. |