在MSBuild中使用注册表属性时引用属性?
发布时间:2020-12-14 03:52:32 所属栏目:Windows 来源:网络整理
导读:我正在尝试使用MSBuild来确定SQL服务器实例是否启用了SQL身份验证.我正在尝试以下方法: Target Name="VerifySQLLoginMode" PropertyGroup SqlInstanceNameSQL08X64/SqlInstanceName SqlInstanceKey$(registry:HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicros
我正在尝试使用MSBuild来确定SQL服务器实例是否启用了SQL身份验证.我正在尝试以下方法:
<Target Name="VerifySQLLoginMode"> <PropertyGroup> <SqlInstanceName>SQL08X64</SqlInstanceName> <SqlInstanceKey>$(registry:HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL ServerInstance NamesSQL@$(SqlInstanceName))</SqlInstanceKey> <SqlLoginMode>$(registry:HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL Server$(SqlInstanceKey)MSSQLServer@LoginMode)</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> 不幸的是,MSBuild似乎不允许在$(registry:…)属性中引用属性($(SqlInstanceName)). 或者有一些方法可以使这项工作? 解决方法
实际上,它可能取决于使用32位MSBuild.使用MSBuild 4.0
property functions给我这个:
<Target Name="VerifySQLLoginMode"> <!-- Note that this can't deal with the default instance. --> <PropertyGroup> <SqlInstanceName>SQL08X64</SqlInstanceName> <SqlInstanceKey>$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL ServerInstance NamesSQL','$(SqlInstanceName)',null,RegistryView.Registry64,RegistryView.Registry32))</SqlInstanceKey> <SqlLoginMode>$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL Server$(SqlInstanceKey)MSSQLServer','LoginMode',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> ……工作正常. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows-phone-7 – 如何从Windows Phone 7或8获取用户自己
- Windows上的TensorFlow:ImportError:没有名为’_pywrap_t
- 如何将ntfs-3g与自制软件链接?
- windows-7 – Windows经典设计有扁平元素
- wpf – 如何在Expression Blend中使用CollectionViewSource
- windows-server-2008 – 除了星期日之外,你能创建一个每天运
- windows-10 – 如何检测Windows 10上的开发者模式是否处于活
- Win10智能客户端默认安装路径
- windows-phone-8 – windows phone 8 Map API GeocodeQuery
- 最小的Windows 2008或2012内存使用量
推荐文章
站长推荐
热点阅读