Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to open a "Welcome" webpage after clicking "Open in Browser" from "dotnetapp:dev" container context menu #4006

Closed
v-xinda opened this issue Jul 13, 2023 · 8 comments · Fixed by #4081

Comments

@v-xinda
Copy link

v-xinda commented Jul 13, 2023

OS: Mac&Windows
Docker Extension Build Version: 20230712.5
.NET Version: 8.0.100-preview.5.23303.2

Repro Steps:

  1. Create a .NET 8.0 MVC project by command dotnet new mvc --name Dotnetapp -> Open it in VS Code.
  2. Make sure the project doesn't have Launch.json file.
  3. Make sure the TargetFramework property inside the .csproj file is equal to net8.0.
  4. F5 -> Select "Docker: Debug in Container" -> Select "Use .NET SDK" -> Pop up a webpage.
  5. Navigate to "Contianers" view -> Right click "dotnetapp:dev" container -> Click "Open in Browser".
  6. Check whether succeeds to open a "Welcome" webpage.

Expect:
Succeed to open a "Welcome" webpage.
Screenshot 2023-07-13 at 16 37 48

Actual:
Fail to open a "Welcome" webpage.
Screenshot 2023-07-13 at 14 27 23

@alexyaang
Copy link
Member

I'm going to look into this as well.

@alexyaang alexyaang self-assigned this Jul 13, 2023
@alexyaang
Copy link
Member

I see what's going on. If you run the .NET SDK build image by right clicking on it in our extension, the ports aren't getting exposed because it's not built in the image. (In other words, the ExposedPort property does not exist in the image because the way a .NET SDK Image is built through dotnet publish). Then if you try to open it in a browser, since there are no ports exposed, browseContainer() can't find any available ports, and thus this issue appears.

@alexyaang alexyaang removed their assignment Jul 13, 2023
@v-xinda
Copy link
Author

v-xinda commented Jul 14, 2023

@alexyaang This issue doesn't reproduce for the cloned "TestSolution" project.
Steps:

  1. Open the cloned "TestSolution" project -> Select "Docker: Debug in Container" -> Select "Use .NET SDK" -> Select "TestWebApp" project.
  2. Navigate to "Contianers" view -> Right click "testwebapp:dev" container -> Click "Open in Browser".

@alexyaang
Copy link
Member

Yeah that makes sense!

@alexyaang
Copy link
Member

For the .NET 8.0 MVC project created by command dotnet new mvc --name Dotnetapp, try adding this to the .csproj file

  <ItemGroup>
    <ContainerPort Include="8080" Type="tcp" />
  </ItemGroup>

It should look something like this and see if this issue still persists.

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <RootNamespace>dotnet_app</RootNamespace>
  </PropertyGroup>
  
  <ItemGroup>
    <ContainerPort Include="8080" Type="tcp" />
  </ItemGroup>

</Project>

@v-xinda
Copy link
Author

v-xinda commented Jul 17, 2023

@alexyaang This issue still reproduces after adding the <ContainerPort Include="8080" Type="tcp" /> to the .csproj file. The details of the .csproj file as below:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>
  <ItemGroup>
    <ContainerPort Include="8080" Type="tcp" />
  </ItemGroup>
</Project>

@alexyaang
Copy link
Member

mhmm interesting, are you trying this on linux containers or windows containers?

@v-xinda
Copy link
Author

v-xinda commented Jul 18, 2023

@alexyaang I test this on the Linux containers. There is a known issue on Windows containers #4005.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants