c# - 由于写权限,单元测试在 Visual Studio Team Services Build runner 上失败?

标签 c# visual-studio tfsbuild xunit azure-devops

我有一个在 Visual Studio Team Services 上运行的构建,它运行一套 XUnit 测试,这些测试都在我的本地计算机上通过。该错误与加载我的项目中引用的 c++ dll (Interface.dll) 有关。当它们在构建服务器上运行时,出现以下错误

2015-12-18T17:40:24.3167397Z ##[error]Error Message:
2015-12-18T17:40:24.3197403Z ##[error]  Microsoft.Practices.Unity.ResolutionFailedException : Resolution of the dependency failed, type = "myapp.EntityModule.Entities.calc", name = "(none)".
2015-12-18T17:40:24.3197403Z ##[error]Exception occurred while: Calling constructor myapp.EntityModule.Entities.calc().
2015-12-18T17:40:24.3207417Z ##[error]Exception is: FileLoadException - Could not load file or assembly 'Interface.DLL' or one of its dependencies. The media is write protected. (Exception from HRESULT: 0x80070013)
2015-12-18T17:40:24.3217444Z ##[error]-----------------------------------------------
2015-12-18T17:40:24.3217444Z ##[error]At the time of the exception, the container was:
2015-12-18T17:40:24.3227399Z ##[error]
2015-12-18T17:40:24.3237398Z ##[error]  Resolving myapp.EntityModule.Entities.calc,(none)
2015-12-18T17:40:24.3237398Z ##[error]  Calling constructor myapp.EntityModule.Entities.calc()
2015-12-18T17:40:24.3247420Z ##[error]
2015-12-18T17:40:24.3247420Z ##[error]---- System.IO.FileLoadException : Could not load file or assembly 'Interface.DLL' or one of its dependencies. The media is write protected. (Exception from HRESULT: 0x80070013)
2015-12-18T17:40:24.3257416Z ##[error]Stack Trace:
2015-12-18T17:40:24.3267400Z ##[error]   at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
2015-12-18T17:40:24.3267400Z ##[error]   at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, String name, IEnumerable`1 resolverOverrides)
2015-12-18T17:40:24.3277398Z ##[error]   at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides)
2015-12-18T17:40:24.3277398Z ##[error]   at Microsoft.Practices.Unity.UnityContainerExtensions.Resolve[T](IUnityContainer container, ResolverOverride[] overrides)
2015-12-18T17:40:24.3287422Z ##[error]   at myapp.EntityModule.Tests.Entities.Car.OutingSetup.OutingsetupTests.GetNewcalc()
2015-12-18T17:40:24.3297428Z ##[error]   at myapp.EntityModule.Tests.Entities.Car.OutingSetup.OutingsetupTests.OutingSetups_Ready_Rule_CasterSlugFrontInRangeWithUpperControlArmForeAdjLength_Right_TestReadyStatusValues(String simDescription, Double casterSlugFront, Double mountAdjustmentLengthFore, ReadyStatus expected)
2015-12-18T17:40:24.3297428Z ##[error]----- Inner Stack Trace -----
2015-12-18T17:40:24.3307426Z ##[error]   at myapp.EntityModule.Entities.Results.DymolaResults..ctor()
2015-12-18T17:40:24.3307426Z ##[error]   at myapp.EntityModule.Entities.calc..ctor()
2015-12-18T17:40:24.3317440Z ##[error]   at lambda_method(Closure , IBuilderContext )
2015-12-18T17:40:24.3317440Z ##[error]   at Microsoft.Practices.ObjectBuilder2.DynamicBuildPlanGenerationContext.<>c__DisplayClass1.<GetBuildMethod>b__0(IBuilderContext context)
2015-12-18T17:40:24.3327420Z ##[error]   at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
2015-12-18T17:40:24.3337422Z ##[error]   at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
2015-12-18T17:40:24.3347418Z ##[error]   at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)

关于如何解决这个问题有什么想法吗?

最佳答案

如果您使用的是 Hosted Agents,您必须知道构建是在没有管理员权限的情况下启动的,但我怀疑您的问题与您机器上的某些东西有关,而不是与它们的环境有关。

要尝试重现,您可以仅使用 VS 2015 和您的代码启动 Azure VM,并尝试运行相同的命令。您也许能够重现并查明您的错误:)

关于c# - 由于写权限,单元测试在 Visual Studio Team Services Build runner 上失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34362619/

相关文章:

c# - WPF,未选中时隐藏文本框

c++ - unique_ptr 的 vector 未被完全删除(内存泄漏)

azure - 当我在 Windows Azure 上交换临时部署和生产部署时出现 "error: 19 - Physical connection is not usable"

msbuild - 如何从 TFS 2015 构建获取预期输出(以匹配我的 XAML 构建)?

c# - 将警告视为 TFS 级别 VS2017 上的错误

c# - 有时在获取文件缩略图时位图是颠倒的

c# - 构建表达式以使用 DateTime 调用 StringBuilder.Append(Object) 时出现异常

c# - 在 WinRT C# 中,如何使用 RenderTargetBitmap 保存屏幕外 XAML 树?

visual-studio - 如何在 SVN 更新后自动执行 Visual Studio 任务?

c# - C#中使用SQL连接将数据添加到表中