gpt4 book ai didi

.net - 在 docker 中执行 "dotnet watch run"不起作用(杀死进程 'dotnet.exe run' : The system cannot find the file specified) 时出错

转载 作者:行者123 更新时间:2023-12-02 18:35:52 24 4
gpt4 key购买 nike

短篇小说

嘿伙计们,在 docker 中运行 “dotnet watch -v run” 不起作用。更改任何文件后(因此应重新启动应用程序时),我得到 'watch: Error while killing process'C:\Program Files\dotnet\dotnet.exe run': The system cannot find the file specified'.

有人知道我做错了什么吗?

容器是如何创建的(看到我正在使用卷,所以当我更新 WebDemo 项目中的文件时,它们会在容器中更新)

docker image build -t test:test ./
docker container run --rm -it --name test --mount type=bind,source=E:\Projects\test\WebDemo,target=C:\src test:test

docker 中的控制台输出

C:\src\WebDemo\WebDemo>dotnet watch -v run
watch : Polling file watcher is enabled
watch : Running MSBuild target 'GenerateWatchList' on 'C:\src\WebDemo\WebDemo\WebDemo.csproj'
watch : Started 'C:\Program Files\dotnet\dotnet.exe' with process id 980
watch : Process id 980 ran for 884ms
watch : Watching 5 file(s) for changes
watch : Started 'C:\Program Files\dotnet\dotnet.exe' with process id 1604
watch : Running dotnet with the following arguments: run
watch : Started
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\src\WebDemo\WebDemo

*HERE IS WHERE THE FILE WAS UPDATED*

watch : Killing process 1604
watch : Error while killing process 'C:\Program Files\dotnet\dotnet.exe run': The system cannot find the file specifi
ed.

TL;DR;

  • 您可以在下面看到我目前使用的是 netcore 3.0 预览版,但我在使用 2.2 时遇到了同样的问题
  • 请注意,重新安装 docker 不会有帮助(因为我生活在 Windows 世界中,所以我将它提升到一个新的水平并尝试重新安装整个 Windows :) - 显然它没有帮助)

dotnet --info(在 docker 中)

.NET Core SDK (reflecting any global.json):
Version: 3.0.100-preview7-012821
Commit: 6348f1068a

Runtime Environment:
OS Name: Windows
OS Version: 10.0.18362
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview7-012821\

Host (useful for support):
Version: 3.0.0-preview7-27912-14
Commit: 4da6ee6450

.NET Core SDKs installed:
3.0.100-preview7-012821 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.0.0-preview7.19365.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.0.0-preview7-27912-14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0-preview7-27912-14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download

泊坞信息

Client:
Debug Mode: false

Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 26
Server Version: 19.03.1
Storage Driver: windowsfilter
Windows:
Logging Driver: json-file
Plugins:
Volume: local
Network: ics l2bridge l2tunnel nat null overlay transparent
Log: awslogs etwlogs fluentd gcplogs gelf json-file local logentries splunk syslog
Swarm: inactive
Default Isolation: hyperv
Kernel Version: 10.0 18362 (18362.1.amd64fre.19h1_release.190318-1202)
Operating System: Windows 10 Pro Version 1903 (OS Build 18362.267)
OSType: windows
Architecture: x86_64
CPUs: 8
Total Memory: 15.87GiB
Name: DESKTOP-1OIN727
ID: WBSQ:ILPO:MZCS:3YXS:MBHF:UHEX:APCV:EFNB:BN6K:OKRC:RNZW:54F3
Docker Root Dir: C:\ProgramData\Docker
Debug Mode: true
File Descriptors: -1
Goroutines: 28
System Time: 2019-08-03T17:25:37.7173124+02:00
EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

Dockerfile

FROM mcr.microsoft.com/dotnet/core/sdk:3.0-nanoserver-1903 AS sdk_layer
WORKDIR src/

COPY WebDemo/*.csproj WebDemo/
RUN dotnet restore ./WebDemo

COPY . ./

最佳答案

这里的问题是 netcore SDK 所基于的 nanoserver 镜像不包含 taskkill.exedotnet watch 用于在重新启动之前杀死 dotnet 进程

I've logged this issue但不幸的是,目前唯一的解决方案是创建基于 servercore 的自定义 netcore SDK 镜像。

关于.net - 在 docker 中执行 "dotnet watch run"不起作用(杀死进程 'dotnet.exe run' : The system cannot find the file specified) 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57339870/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com