NUnit 失败 "Inaccessible logs: Security"
NUnit fails with "Inaccessible logs: Security"
我正在将一个构建服务从一个古老的 Windows XP 服务器迁移到 Windows Server 2K12 R2,现在我遇到了似乎是权限问题的问题:
在我构建的 "integration test" 步骤中,NUnit 失败:
Errors and Failures:
1) SetUp Error : Hidden.UAC.Service.IntegrationTest.TestSetUp
SetUp : System.Security.SecurityException : The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.
at System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly, Boolean wantToCreate)
at System.Diagnostics.EventLog.SourceExists(String source, String machineName, Boolean wantToCreate)
at Hidden.Cornerstone.Common.ApplicationManager.LogException(Exception e) in e:\Builder\TeamCity\buildAgent\workdbde7d05f17a8e5\Hidden.Cornerstone\Hidden.Cornerstone.Common\ApplicationManager.cs:line 99
at Hidden.Cornerstone.Common.ApplicationManager.Initialize() in e:\Builder\TeamCity\buildAgent\workdbde7d05f17a8e5\Hidden.Cornerstone\Hidden.Cornerstone.Common\ApplicationManager.cs:line 91
at Hidden.UAC.Service.IntegrationTest.TestSetUp.Init() in e:\Builder\TeamCity\buildAgent\workdbde7d05f17a8e5\Hidden.UAC\Hidden.UAC.Service.Impl.IntegrationTest\TestSetUp.cs:line 22
构建代理是 运行 作为用户 BuildSrvService。我在 Windows Server 2012 R2 Datacenter 服务器上使用 TeamCity Professional 9.1.7 和 NUnit 2.6.4。
我假设这里的解决方案是以某种方式向用户 运行 生成代理授予对事件日志的适当权限,但我在这里需要一点帮助:-)
由于一些兼容性问题,我们 - 现在 - 坚持使用在 .net 3.5 上运行的旧版本的 NUnit。 Windows Server 2003 引入的一项安全更改要求应用程序在被授予访问事件日志之前进行注册。
有关详细信息,请参阅 and 。
快速修复:确定您的应用程序名称(在您的源代码中查找 EventLog.CreateEventSource)并更新您的注册表提升的 PowerShell:
PS> $RegistryBase = "HKLM:\SYSTEM\CurrentControlSet\Services\EventLog\Application"
PS> $ApplicationName = "MyApplicationName"
PS> New-Item `
-Force `
-Path $RegistryBase `
-Name $ApplicationName
PS> New-ItemProperty `
-Force `
-Path "$RegistryBase$ApplicationName" `
-Name "EventMessageFile" `
-PropertyType ExpandString `
-Value "%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\EventLogMessages.dll"
我正在将一个构建服务从一个古老的 Windows XP 服务器迁移到 Windows Server 2K12 R2,现在我遇到了似乎是权限问题的问题:
在我构建的 "integration test" 步骤中,NUnit 失败:
Errors and Failures:
1) SetUp Error : Hidden.UAC.Service.IntegrationTest.TestSetUp
SetUp : System.Security.SecurityException : The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.
at System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly, Boolean wantToCreate)
at System.Diagnostics.EventLog.SourceExists(String source, String machineName, Boolean wantToCreate)
at Hidden.Cornerstone.Common.ApplicationManager.LogException(Exception e) in e:\Builder\TeamCity\buildAgent\workdbde7d05f17a8e5\Hidden.Cornerstone\Hidden.Cornerstone.Common\ApplicationManager.cs:line 99
at Hidden.Cornerstone.Common.ApplicationManager.Initialize() in e:\Builder\TeamCity\buildAgent\workdbde7d05f17a8e5\Hidden.Cornerstone\Hidden.Cornerstone.Common\ApplicationManager.cs:line 91
at Hidden.UAC.Service.IntegrationTest.TestSetUp.Init() in e:\Builder\TeamCity\buildAgent\workdbde7d05f17a8e5\Hidden.UAC\Hidden.UAC.Service.Impl.IntegrationTest\TestSetUp.cs:line 22
构建代理是 运行 作为用户 BuildSrvService。我在 Windows Server 2012 R2 Datacenter 服务器上使用 TeamCity Professional 9.1.7 和 NUnit 2.6.4。
我假设这里的解决方案是以某种方式向用户 运行 生成代理授予对事件日志的适当权限,但我在这里需要一点帮助:-)
由于一些兼容性问题,我们 - 现在 - 坚持使用在 .net 3.5 上运行的旧版本的 NUnit。 Windows Server 2003 引入的一项安全更改要求应用程序在被授予访问事件日志之前进行注册。
有关详细信息,请参阅 and 。
快速修复:确定您的应用程序名称(在您的源代码中查找 EventLog.CreateEventSource)并更新您的注册表提升的 PowerShell:
PS> $RegistryBase = "HKLM:\SYSTEM\CurrentControlSet\Services\EventLog\Application"
PS> $ApplicationName = "MyApplicationName"
PS> New-Item `
-Force `
-Path $RegistryBase `
-Name $ApplicationName
PS> New-ItemProperty `
-Force `
-Path "$RegistryBase$ApplicationName" `
-Name "EventMessageFile" `
-PropertyType ExpandString `
-Value "%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\EventLogMessages.dll"