gpt4 book ai didi

asp.net - Dotnet Core 2 docker :找不到与命令 “dotnet-watch”匹配的可执行文件

转载 作者:行者123 更新时间:2023-12-02 18:22:38 25 4
gpt4 key购买 nike

我正在尝试为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-compose环境中运行该docker文件时,它一直在喊:

No executable found matching command "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上工作?

最佳答案

我只需要像这样在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

关于asp.net - Dotnet Core 2 docker :找不到与命令 “dotnet-watch”匹配的可执行文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46550560/

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