开发者

FileIOPermission SecurityException when running Xunit in TFS

I'm attempting to integrate Xunit tests into our TFS build.

I have placed xunit.runner.msbuild.dll and xunit.runner.utility.dll in a folder "C:\Program Files\MSBuild\Xunit". I have a task in the build file to call into the Xunit task:

<UsingTask AssemblyFile="$(MSBuildExtensionsPath)\Xunit\xunit.runner.msbuild.dll" TaskName="Xunit.Runner.MSBuild.xunit"/>
.....
<xunit Assembly="$(DropLocation)\$(BuildNumber)\Release\MyDll.dll" Html="TestRun.htm" />

I'm getting an error which I have no idea how to debug. I have tried giving the "Everyone" user full control on the Xunit folder.

D:\bld\141\BuildType\Test.proj(50,3): error : System.Security.SecurityException: Request for the permi开发者_运维百科ssion of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
  D:\bld\141\BuildType\Test.proj(50,3): error :    at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
  D:\bld\141\BuildType\Test.proj(50,3): error :    at System.Security.CodeAccessPermission.Demand()
  D:\bld\141\BuildType\Test.proj(50,3): error :    at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
  D:\bld\141\BuildType\Test.proj(50,3): error :    at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
  D:\bld\141\BuildType\Test.proj(50,3): error :    at Xunit.Sdk.Executor..ctor(String assemblyFilename)
  D:\bld\141\BuildType\Test.proj(50,3): error :    at Xunit.ExecutorWrapper.RethrowWithNoStackTraceLoss(Exception ex)
  D:\bld\141\BuildType\Test.proj(50,3): error :    at Xunit.ExecutorWrapper.CreateObject(String typeName, Object[] args)
  D:\bld\141\BuildType\Test.proj(50,3): error :    at Xunit.ExecutorWrapper..ctor(String assemblyFilename, String configFilename, Boolean shadowCopy)
  D:\bld\141\BuildType\Test.proj(50,3): error :    at Xunit.Runner.MSBuild.xunit.ExecuteAssembly(String assemblyFilename, String configFilename, IRunnerLogger logger)


By default, the TFS Build Service runs as "Network Service." You can check this by inspecting the "Identity" tab of the Properties dialog for the Team Foundation Build Service in Service Control Manager (services.msc) on the build machine. If you're using TFS 2010, you can also check the identity in the TFS Administration Console on the build machine.

Somewhat surprisingly, the "Everyone" group does not include the "Network Service" account. So, you'll want to grant read/execute privileges to your XUnit folder to the Network Service account. I'm assuming that it's a local folder and not a network share.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜