伙计们,在docker内部运行“ dotnet watch -v run” 无效。更改任何文件后(因此应重新启动应用程序时),我得到“手表:杀死进程时出错”:C:\ Program Files \ dotnet \ dotnet.exe运行”:系统找不到指定的文件。” / strong>
有人知道我在做什么错吗?
容器的创建方式(请参见我正在使用卷,因此当我在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.
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 . ./
答案 0 :(得分:0)
这里的问题是netcore SDK所基于的nanoserver映像不包含taskkill.exe
,dotnet watch
使用int sum {0};
for (int i = 1; i <= 15; i += 2)
sum += i;
来杀死dotnet进程,然后重新启动它。
I've logged this issue,但不幸的是,目前唯一的解决方案是基于servercore创建自定义的netcore SDK映像。