2016-05-13 48 views
1

我搬迁从一个古老的Windows XP到Windows Server R2 2K12构建服务,现在我只能和这似乎是一个权限问题:NUnit的失败,“无法访问日志:安全”

在我构建的“集成测试”的步骤,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\work\9dbde7d05f17a8e5\Hidden.Cornerstone\Hidden.Cornerstone.Common\ApplicationManager.cs:line 99 
    at Hidden.Cornerstone.Common.ApplicationManager.Initialize() in e:\Builder\TeamCity\buildAgent\work\9dbde7d05f17a8e5\Hidden.Cornerstone\Hidden.Cornerstone.Common\ApplicationManager.cs:line 91 
    at Hidden.UAC.Service.IntegrationTest.TestSetUp.Init() in e:\Builder\TeamCity\buildAgent\work\9dbde7d05f17a8e5\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。

我在这里假设的解决方案是以某种方式授予对事件日志到运行生成代理用户适当的权限,但我在这里:-)

回答

1

需要一点帮助。由于一对夫妇的兼容性问题,我们现在正在坚持在.NET 3.5上运行的旧版NUnit。随Windows Server 2003引入的安全更改要求应用程序在被授予对事件日志的访问权限之前进行注册。

请参阅https://stackoverflow.com/a/7848414/1353645https://stackoverflow.com/a/4603820/1353645了解更多信息。

快速修复:搞清楚你的​​应用程序名称(寻找在源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"