我尝试在持续集成过程中在VSTS上发布我的单元测试,我使用docker,并且在执行发布任务时,我仍然收到以下错误,因此找不到dotnet test命令生成的xml文件。
No test result files matching **\test-results.xml were found.
Run Code Online (Sandbox Code Playgroud)
如果我在本地运行命令docker-compose run web-tests,则会创建一个tests-results文件夹,其中包含预期的test-results.xml文件。
我在VSTS上做错了什么?
代码仓库:Github
我的文件夹架构:
web/
??? web/
? ??? web.csproj
? ??? Dockerfile
?
??? web.test/
? ??? web.test.csproj
?
??? web.sln
??? docker-compose.yml
??? docker-compose.override.yml
Run Code Online (Sandbox Code Playgroud)
Dockerfile(编辑删除多余的dotnet测试命令):
FROM microsoft/aspnetcore:2.0 AS base
WORKDIR /app
EXPOSE 80
FROM microsoft/aspnetcore-build:2.0 AS build
WORKDIR /src
COPY web.sln ./
COPY web/web.csproj web/
COPY web.test/web.test.csproj web.test/
RUN dotnet restore -nowarn:msb3202,nu1503
COPY . .
WORKDIR /src/web
RUN dotnet build -c …Run Code Online (Sandbox Code Playgroud) 感谢此Vs code 教程,我成功地使用 docker-compose 文件在 Ubuntu WSL-2 发行版(在 Windows 10 上)中调试了 asp .net core 3.1 应用程序
但考虑到我们使用命令启动容器docker-compose up ,然后附加调试器,所有设置的断点Program.cs或都Startup.cs不会命中。事实上,当我手动附加调试器时,应用程序已经处理了这些文件,但为时已晚。所有其他断点(在控制器或后台进程中......)均被正确命中。
当使用 Visual Studio 2019 Community 调试同一项目时,我的所有断点都会被命中,即使是Program.cs或Startup.cswhich 中的断点也是此处的预期行为。
我究竟做错了什么 ?
docker-compose -f "docker-compose.debug.yml" up -d --build)version: '3.7'
services:
myapp:
image: myapp
container_name: myapp
build:
context: .
dockerfile: src/MyApp/src/Dockerfile
ports:
- "60713:80"
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://+:80
volumes:
- ~/.vsdbg:/remote_debugger:rw
networks:
default:
external:
name: mynetwork
Run Code Online (Sandbox Code Playgroud)
{ …Run Code Online (Sandbox Code Playgroud) 我使用 Serilog 和 Elasticsearch 接收器将我的日志推送到 Elastic,以及 .net 5 应用程序中 APM 中的事务。
创建 Logger 时,它使用当前日期时间作为索引格式 (mslogs-yyyy.MM.dd) 的一部分,但一旦容器运行,无论当前时间如何,这仍然是所使用的相同索引名称。例如,如果容器于 2021 年 6 月 25 日启动,则索引将创建并mslogs-2021.06.25在容器的整个生命周期内保留,因此接下来几天生成的日志仍会推送到该索引中。
当我的操作人员在 Elk 上设置删除旧日志的策略时,根据索引名称(日期时间部分),新日志可能会被删除,因为它们被放入“旧索引”中。
这是我的记录器生成器
public static Logger GetELKLogger(IConfiguration config, string varEnv = "ElasticSearchLog")
{
var configuration = config.Get<Configuration>(varEnv);
return new LoggerConfiguration()
.ReadFrom.Configuration(config)
.Enrich.WithElasticApmCorrelationInfo()
.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri(configuration.ElasticSearchLog))
{
AutoRegisterTemplate = true,
IndexFormat = $"mslogs-{DateTime.UtcNow:yyyy.MM.dd}", // called once at startup !!
DetectElasticsearchVersion = true,
RegisterTemplateFailure = RegisterTemplateRecovery.IndexAnyway,
AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv7,
FailureCallback = e => Console.WriteLine($"Unable to submit event …Run Code Online (Sandbox Code Playgroud) docker ×2
.net ×1
.net-core ×1
asp.net-core ×1
azure-devops ×1
c# ×1
serilog ×1
unit-testing ×1
wsl-2 ×1