Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Reference
MSBuild
MSBuild Concepts
MSBuild Properties
 Registry Look-Ups
Visual Studio
Registry Look-Ups

Some build tasks require the input of paths and other information that is contained in registry keys or in environment variables. A build configuration file, such as msbuild.exe.config, can read these values directly from the registry,

The $(registry:xxxx) syntax can be used anywhere in the project where property expressions are enabled. In such cases, if there is an error, an "invalid project file" error message occurs that explains the problem.

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.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content      
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker