azure-devops - 由 Azure Devops Server 代理运行时单元测试找不到文件
问题描述
在app.config
文件中有对另一个配置文件的引用。
<system.web>
<roleManager configSource="Roles.config"/>
当从 Visual Studio 执行测试用例时,一切正常。但是,如果它由自托管代理从 Azure Devops Server 运行,则会引发以下异常:
System.Configuration.ConfigurationErrorsException: Unable to open configSource file 'Roles.config'.
该文件始终复制到 bin 目录。
有任何想法吗?
Roles.config
更新:经过一番调查,发现临时工作文件夹中没有文件:agent\_work\2\s\TestResults\Deploy_srv 2020-05-15 14_46_18\Out\
YAML 的一小部分
- task: VSTest@2
displayName: 'Test Assemblies'
inputs:
testAssemblyVer2: |
**\$(BuildConfiguration)\One.dll
**\$(BuildConfiguration)\Two.dll
解决方案
有任何想法吗?
也许您可以查看以下提示以进行故障排除:
1.首先你应该确保Roles.config
文件在版本控制之下。
2.然后确保此文件的复制选项设置为始终复制,检查您的项目文件(xx.xxproj)并检查它是否存在:
<xxx Include="Roles.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</xxx>
3.由于该configSource
属性使用相对路径,因此您应确保该Roles.config
文件与您的 app.config 文件位于同一目录下。
推荐阅读
- javascript - 在另一个函数中传递函数参数
- forms - Symfony DataMapper 不更新对象
- reactjs - 在 React 中更改作为组件引入的 SVG 元素的颜色
- php - 匹配姓名首字母的正则表达式 - PCRE
- image - 将完整的图像序列输入网络还是一次输入一帧?
- javascript - 从 getElementsByClassName 中排除子类
- c# - 使用gridview在itemtemplate上自定义分页
- javascript - jQuery获取选择的新选择/未选择元素的值
- database - 如何理解Mongo监视器中的“scanned”和“scanned_objects”?
- groovy - Groovy:日期时间增量和 JsonOutput.toJson