我正在尝试为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
如果我跑:
dotnet restore
dotnet watch run
从同一个文件夹中,一切似乎都运行得很好(观察者开始)。当我改为运行该docker文件(在docker-compose环境中)时,它一直在喊:
找不到匹配命令“dotnet-watch”
的可执行文件
我的配置文件如下:
<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>
并且你可以看到包含臭名昭着的:
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.0" />
这通常是造成问题的原因。
如何让dotnet watch
在docker上工作?
答案 0 :(得分:2)
我只需dotnet restore
ENTRYPOINT
就像这样:
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