[英]Dotnet core 2 docker: No executable found matching command "dotnet-watch"
I'm trying to create a development Dockerfile
for dotnet core 2. What I have so far is the following:我正在尝试为 dotnet core 2 创建一个开发Dockerfile
。到目前为止我所拥有的是以下内容:
FROM microsoft/aspnetcore-build:2.0
VOLUME /app
WORKDIR /app
COPY . ./
ENV ASPNETCORE_SERVER.URLS http://*:5000
ENV ASPNETCORE_ENVIRONMENT Development
RUN dotnet restore
ENTRYPOINT dotnet watch run --configuration Debug
If I run:如果我运行:
dotnet restore
dotnet watch run
From the same folder everything seems to work just fine (the watcher starts).在同一个文件夹中,一切似乎都很好(观察者启动)。 When I instead run that docker file (inside a docker-compose environment) it keeps shouting:当我运行该 docker 文件(在 docker-compose 环境中)时,它一直在喊:
No executable found matching command "dotnet-watch"找不到与命令“dotnet-watch”匹配的可执行文件
My configuration file is the following:我的配置文件如下:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
</Project>
and as you can see contains the infamous:正如你所看到的,包含臭名昭著的:
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.0" />
line that is usually what's causing the issue.这通常是导致问题的原因。
How can I make dotnet watch
work on docker?如何让dotnet watch
在 docker 上工作?
I just had to dotnet restore
in the ENTRYPOINT
like this:我只需要像这样在ENTRYPOINT
dotnet restore
:
FROM microsoft/aspnetcore-build:2.0
VOLUME /app
WORKDIR /app
COPY . ./
ENV ASPNETCORE_SERVER.URLS http://*:5000
ENV ASPNETCORE_ENVIRONMENT Development
ENTRYPOINT dotnet restore && dotnet watch run --configuration Debug
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.