Actually, perhaps this is due to the use of 32-bit MSBuild. Using MSBuild 4.0's property functions gives me the following:
<Target Name="VerifySQLLoginMode"> <PropertyGroup> <SqlInstanceName>SQL08X64</SqlInstanceName> <SqlInstanceKey>$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL', '$(SqlInstanceName)', null, RegistryView.Registry64, RegistryView.Registry32))</SqlInstanceKey> <SqlLoginMode>$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\$(SqlInstanceKey)\MSSQLServer', 'LoginMode', null, RegistryView.Registry64, RegistryView.Registry32))</SqlLoginMode> </PropertyGroup> <Message Text="SqlInstanceName: $(SqlInstanceName)" /> <Message Text="SqlInstanceKey: $(SqlInstanceKey)" /> <Message Text="SqlLoginMode: $(SqlLoginMode)" /> <Error Condition="'$(SqlLoginMode)' != '2'" Text="Error: SQL Authentication is disabled. Please enable it." /> </Target>
... which works great.
source share