gpt4 book ai didi

c# - Visual Studio 2017 中的 Docker ASP.NET CORE 2.1 应用程序。应用程序未在 Debug模式下启动

转载 作者:行者123 更新时间:2023-11-30 22:57:16 27 4
gpt4 key购买 nike

我一直在开发 Web 应用程序 ASP.NET CORE 2.1,并愉快地在 Visual Studio 中使用 Docker 运行它。到目前为止。

Out of blue when I try to start debugging it does the build part, but completely skips the running part. So now I am unable to debug my Docker container with Visual Studio 2017.

没有显示任何错误,一切似乎都很好,除了应用程序没有启动这一事实。调试输出甚至不在“输出”选项卡中的可用列表中。容器似乎正在运行,但出于某种原因,Visual Studio 未附加到 Docker 镜像以进行调试。

如有任何帮助,我们将不胜感激。

重新启动 Visual Studio 或计算机,删除 bin、obj、.vs、%userprofile%\vsdbg 和 %userprofile%\onecoremsvsmon 没有任何区别。这是我的环境:

  1. Windows10
  2. Microsoft Visual Studio Enterprise 2017 版本 15.9.4
  3. VisualStudio.15.Release/15.9.4+28307.222
  4. ASP.NET Core Razor 语言服务 15.8.31590
  5. Microsoft Visual Studio 容器工具 1.1
  6. 适用于容器的 Visual Studio 工具 1.0

docker :

  1. 版本 2.0.0.0-win81 (29211)
  2. 内部版本:4271b9e
  3. 引擎:18.09.0
  4. 撰写:1.23.2
  5. 机器:0.16.0

容器似乎正在运行:

CONTAINER ID        IMAGE               COMMAND               CREATED             STATUS              PORTS                                                                 NAMES
22852e61b41a dockertest "tail -f /dev/null" 4 minutes ago Up 4 minutes 0.0.0.0:50659->80/tcp, 0.0.0.0:44304->443/tcp priceless_pare

docker 文件:

FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY ["Dockertest/Dockertest.csproj", "Dockertest/"]
RUN dotnet restore "Dockertest/Dockertest.csproj"
COPY . .
WORKDIR "/src/Dockertest"
RUN dotnet build "Dockertest.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "Dockertest.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Dockertest.dll"]

VS 构建输出:

Target ContainerPrepareForLaunch:
Using "ResolveVsDbgPath" task from assembly "C:\Users\aaaa\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.0.2105168\build\..\tools\Microsoft.VisualStudio.Containers.Tools.Tasks.dll".
Task "ResolveVsDbgPath"
Done executing task "ResolveVsDbgPath".
Task "ContainerError" skipped, due to false condition; ('$(TargetFrameworkIdentifier)' == '.NETCoreApp' And
'@(_Dockerfile->AnyHaveMetadataValue('TargetOS', 'Linux'))' == 'true' And
!Exists('$(ContainerVsDbgPath)\vsdbg')) was evaluated as ('.NETCoreApp' == '.NETCoreApp' And
'true' == 'true' And
!Exists('C:\Users\aaaa\vsdbg\vs2017u5\vsdbg')).
Using "ResolveMsVsMonPath" task from assembly "C:\Users\aaaa\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.0.2105168\build\..\tools\Microsoft.VisualStudio.Containers.Tools.Tasks.dll".
Task "ResolveMsVsMonPath"
Done executing task "ResolveMsVsMonPath".
Using "PrepareForLaunch" task from assembly "C:\Users\aaaa\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.0.2105168\build\..\tools\Microsoft.VisualStudio.Containers.Tools.Tasks.dll".
Task "PrepareForLaunch"
docker build -f "C:\Projects\Dockertest\Dockerfile" -t dockertest --label "com.microsoft.created-by=visual-studio" "C:\Projects"
Sending build context to Docker daemon 3.007GB

Step 1/18 : FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
---> 1fe6774e5e9e
Step 2/18 : WORKDIR /app
---> Using cache
---> 930ee0770e2d
Step 3/18 : EXPOSE 80
---> Using cache
---> 4f184a8a4bd4
Step 4/18 : EXPOSE 443
---> Using cache
---> bdf7dc4e92fd
Step 5/18 : FROM microsoft/dotnet:2.1-sdk AS build
---> 04868b49e01f
Step 6/18 : WORKDIR /src
---> Using cache
---> c27b25a30aeb
Step 7/18 : COPY ["Dockertest/Dockertest.csproj", "Dockertest/"]
---> Using cache
---> 009cbf61e5ae
Step 8/18 : RUN dotnet restore "Dockertest/Dockertest.csproj"
---> Using cache
---> 9baf38b818c8
Step 9/18 : COPY . .
---> ae210461c587
Step 10/18 : WORKDIR "/src/Dockertest"
---> Running in 024c6719cbd3
Removing intermediate container 024c6719cbd3
---> f398384b2049
Step 11/18 : RUN dotnet build "Dockertest.csproj" -c Release -o /app
---> Running in cacc4471c224
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Restore completed in 57.06 ms for /src/Dockertest/Dockertest.csproj.
Dockertest -> /app/Dockertest.dll
Dockertest -> /app/Dockertest.Views.dll
Build succeeded.
0 Warning(s)
0 Error(s)

Time Elapsed 00:00:09.30
Removing intermediate container cacc4471c224
---> 5854863d47c7
Step 12/18 : FROM build AS publish
---> 5854863d47c7
Step 13/18 : RUN dotnet publish "Dockertest.csproj" -c Release -o /app
---> Running in 69df3a178cd7
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Restore completed in 67.48 ms for /src/Dockertest/Dockertest.csproj.
Dockertest -> /src/Dockertest/bin/Release/netcoreapp2.1/Dockertest.dll
Dockertest -> /src/Dockertest/bin/Release/netcoreapp2.1/Dockertest.Views.dll
Dockertest -> /app/
Removing intermediate container 69df3a178cd7
Step 14/18 : FROM base AS final
---> 766815671751
---> bdf7dc4e92fd
Step 15/18 : WORKDIR /app
---> Using cache
---> 61f28b8a64fa
Step 16/18 : COPY --from=publish /app .
---> 6b6711105d65
Step 17/18 : ENTRYPOINT ["dotnet", "Dockertest.dll"]
---> Running in f3be0a8361ee
Removing intermediate container f3be0a8361ee
---> 774100a76bc9
Step 18/18 : LABEL com.microsoft.created-by=visual-studio
---> Running in 76d649057957
Removing intermediate container 76d649057957
---> dbf49735c067
Successfully built dbf49735c067
Successfully tagged dockertest:latest
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.
docker rm -f ce37c3274e9a73fdfeb0b5cb48d451cf3fea687ee3b5c91388ecad1d1f695149
ce37c3274e9a73fdfeb0b5cb48d451cf3fea687ee3b5c91388ecad1d1f695149
docker run -dt -v "C:\Users\aaaa\vsdbg\vs2017u5:/remote_debugger:rw" -v "C:\Users\aaaa\AppData\Roaming\ASP.NET\Https:/root/.aspnet/https:ro" -v "C:\Users\aaaa\AppData\Roaming\Microsoft\UserSecrets:/root/.microsoft/usersecrets:ro" -e "ASPNETCORE_URLS=https://+:443;http://+:80" -e "ASPNETCORE_HTTPS_PORT=44304" -e "ASPNETCORE_ENVIRONMENT=Development" -p 50659:80 -p 44304:443 --entrypoint tail dockertest -f /dev/null
22852e61b41ad164632588db2b4027ad59cc5e876956fb99c7e8eadcbcfcdd77
Done executing task "PrepareForLaunch".
Target "_CheckForInvalidConfigurationAndPlatform" skipped. Previously built successfully.
Target "_CheckForInvalidConfigurationAndPlatform" skipped. Previously built successfully.
Target ReportTypeScriptVersion:
Using "FormatLocalizedString" task from assembly "C:\Program Files (x86)\Microsoft SDKs\TypeScript\3.1\build\TypeScript.Tasks.dll".
Task "FormatLocalizedString"
Done executing task "FormatLocalizedString".
Task "FormatLocalizedString" skipped, due to false condition; ('$(TypeScriptVersionCheckResult)' == 'Downgrade' OR '$(TypeScriptVersionCheckResult)' == 'Upgrade') was evaluated as ('NoneSpecified' == 'Downgrade' OR 'NoneSpecified' == 'Upgrade').
Task "Warning" skipped, due to false condition; ('$(TypeScriptShowVersionWarning)' == 'true' AND '$(TypeScriptVersionCheckResult)' == 'NoneSpecified') was evaluated as ('' == 'true' AND 'NoneSpecified' == 'NoneSpecified').
Task "Warning" skipped, due to false condition; ('$(TypeScriptShowVersionWarning)' == 'true' AND ('$(TypeScriptVersionCheckResult)' == 'Downgrade' OR '$(TypeScriptVersionCheckResult)' == 'Upgrade')) was evaluated as ('' == 'true' AND ('NoneSpecified' == 'Downgrade' OR 'NoneSpecified' == 'Upgrade')).
Task "Warning" skipped, due to false condition; ('$(TypeScriptBuildMode)' == 'true' AND ($(TypeScriptToolsVersion.StartsWith('2.')) OR $(TypeScriptToolsVersion.StartsWith('1.')))) was evaluated as ('' == 'true' AND (False OR False)).
Target Build:
Target CleanupEmptyRefsFolder:
Using "RemoveDir" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "RemoveDir"
Directory "C:\Projects\Dockertest\bin\Release\netcoreapp2.1\refs" doesn't exist. Skipping.
Done executing task "RemoveDir".
Target "ExecuteToolsTarget" skipped, due to false condition; ('@(ToolsTarget)' != '') was evaluated as ('' != '').
Target "_PackAsBuildAfterTarget" skipped, due to false condition; ('$(GeneratePackageOnBuild)' == 'true' AND '$(IsInnerBuild)' != 'true') was evaluated as ('false' == 'true' AND '' != 'true').
Target "DotNetPublish" skipped, due to false condition; ( '$(DeployOnBuild)' == 'true' ) was evaluated as ( '' == 'true' ).

Done building project "Dockertest.csproj".

Build succeeded.
0 Warning(s)
0 Error(s)

Time Elapsed 00:04:53.13
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

编辑:请注意,VS 在以下任务中“坐下”“时间太长”(在该步骤更快之前):

docker build -f "C:\Projects\Dockertest\Dockerfile" -t dockertest  --label "com.microsoft.created-by=visual-studio" "C:\Projects"

最佳答案

好的,现在一切正常!我在一堆拉扯的头发上跳来跳去,不是因为我现在完全没有毛,而是因为我已经修好了!:)))

事不宜迟,以下是打破僵局的内容:由于某种原因,Windows 版 Docker 失去了与项目所在驱动器的“连接”(可能是因为缺少更好的词或权限?)。这正是我为纠正这种情况所做的:

  1. 打开 Docker For Window“设置”菜单
  2. 转到“共享驱动器”
  3. 未选中项目所在驱动器的“共享”复选框(标记已存在)
  4. 点击“应用”按钮
  5. 再次选中“共享”复选框并再次单击“应用”按钮。

在最后一步,登录框弹出两次,告诉我,Docker 需要我的凭据才能访问驱动器。域名已预先填入我的登录名。我两次都输入了密码并单击了“确定”按钮。然后我开始了项目,瞧,我的 Web 应用程序的登录页面按预期显示在浏览器中。简单,却如此狡猾!:))

老实说,在我忙于解决问题的同时,我还清理了我的驱动器以释放一些空间。我已经向野外发布了大约 10 GB。 IDK,无论这是否对成功有贡献,但我读到过,有些人也这样做了,这对 Docker 是有益的。

关于c# - Visual Studio 2017 中的 Docker ASP.NET CORE 2.1 应用程序。应用程序未在 Debug模式下启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53768976/

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