- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
由于这个 Vs code tutorial,我使用 docker-compose 文件成功调试了 Ubuntu WSL-2 发行版(在 Windows 10 上)中的 asp .net core 3.1 应用程序
但考虑到我们使用 docker-compose up
命令启动容器,然后我们附加调试器,所有断点都在 Program.cs
或 Startup 中设置。 cs
没有被击中。事实上,当我手动附加调试器时,应用程序已经处理了这些文件,为时已晚。所有其他断点(在 Controller 或后台进程中......)都被正确击中。
当使用 Visual Studio 2019 Community 调试同一个项目时,我的所有断点都被命中,甚至是 Program.cs
或 Startup.cs
中的断点,这是此处的预期行为.
我做错了什么?
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
{
"version": "0.2.0",
"configurations": [
{
"name": "Docker .NET Core Attach (Preview)",
"containerName": "myapp",
"type": "docker",
"request": "attach",
"platform": "netCore",
"sourceFileMap": {
"/src": "${workspaceFolder}"
}
}
]
}
确实,如果我在容器启动之前启动 VS 代码调试器,我会收到以下错误消息
Error: Process 'docker exec -i "myapp...' exited with code 1
Error: Error: No such container: myapp
最佳答案
我打开了一个 Issue on Github此处提供的回复:
Right now our only supported story for that is to launch it manually and then attach.We have an issue to add "real" compose debugging (microsoft/vscode-docker#840) ...
... the only way to debug startup code is to add something like: while (!Debugger.IsAttached) { Thread.Sleep(100); } to the beginning of your startup code so that it will not proceed until a debugger is attached
总而言之,在 Microsoft 在 VSCode 上或通过临时扩展提供解决方案之前,一种解决方案是添加一些等待代码:
public static IHostBuilder CreateHostBuilder(string[] args)
{
if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == Environments.Development)
{
while (!Debugger.IsAttached) { Thread.Sleep(100); }
}
关于docker - 如何在 VsCode 的 docker 中调试我的 Startup.cs(调试器附加得太晚了),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64553243/
我的 CollapsingToolbarLayout 工作不够准确。图 1 显示了初始状态,图 2 显示了我向下滚动时的状态。过渡发生得太早,它将以(在这种情况下)粉红色的空白区域结束。再次向上滚动时
我是一名优秀的程序员,十分优秀!