Skip to content

Commit 79b0332

Browse files
committed
Edits for .NET SDK container build type
1 parent 48693d6 commit 79b0332

6 files changed

+21
-9
lines changed

Diff for: docs/containers/container-build.md

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ ms.topic: how-to
99
---
1010
# Customize Docker containers in Visual Studio
1111

12+
::: moniker range=">=vs-2022"
13+
> [!NOTE]
14+
> This article describes how you can customize your Docker containers when you choose the Dockerfile container build type. If you are using the .NET SDK build type, the customization options are different, and the information in this article is not applicable.
15+
::: moniker-end
16+
1217
You can customize your container images by editing the Dockerfile that Visual Studio generates when you add Docker support to your project. Whether you're building a customized container from the Visual Studio IDE, or setting up a command-line build, you need to know how Visual Studio uses the Dockerfile to build your projects. You need to know such details because, for performance reasons, Visual Studio follows a special process for building and running containerized apps that isn't obvious from the Dockerfile.
1318

1419
Suppose you want to make a change in the Dockerfile and see the results in both debugging and in production containers. In that case, you can add commands in the Dockerfile to modify the first stage (usually `base`). See [Modify the container image for debugging and production](#modify-container-image-for-debugging-and-production). But, if you want to make a change only when debugging, but not production, then you should create another stage, and use the `DockerfileFastModeStage` build setting to tell Visual Studio to use that stage for debug builds. See [Modify the container image only for debugging](#modify-container-image-only-for-debugging).

Diff for: docs/containers/container-launch-settings.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.topic: reference
99
---
1010
# Container Tools launch settings
1111

12-
In the *Properties* folder in an ASP.NET Core project, you can find the launchSettings.json file, which contains settings that control how your web app is started on your development machine. For detailed information on how this file is used in ASP.NET development, see [Use multiple environments in ASP.NET Core](/aspnet/core/fundamentals/environments?view=aspnetcore-2.2&preserve-view=true). In *launchSettings.json*, the settings in the **Docker** section are related to how Visual Studio handles containerized apps.
12+
In the *Properties* folder in an ASP.NET Core project, you can find the *launchSettings.json* file, which contains settings that control how your web app is started on your development machine. For detailed information on how this file is used in ASP.NET development, see [Use multiple environments in ASP.NET Core](/aspnet/core/fundamentals/environments?view=aspnetcore-2.2&preserve-view=true). In *launchSettings.json*, the settings in the **Docker** section are related to how Visual Studio handles containerized apps.
1313

1414
```json
1515
"Docker": {
@@ -27,7 +27,13 @@ In the *Properties* folder in an ASP.NET Core project, you can find the launchSe
2727
}
2828
```
2929

30-
The commandName setting identifies that this section applies to Container Tools. The following table shows the properties that can be set in this section:
30+
The commandName setting identifies that this section applies to Container Tools.
31+
32+
:::moniker range=">=vs-2022"
33+
Most of the settings in *launchSettings.json* are available and applicable whether you're using a Dockerfile, or using the .NET SDK's built-in container build support (available for .NET 7 and later).
34+
:::moniker-end
35+
36+
The following table shows the properties that can be set in this section:
3137

3238
::: moniker range="vs-2019"
3339

@@ -53,7 +59,7 @@ The commandName setting identifies that this section applies to Container Tools.
5359
| Setting name | Example | Description |
5460
| -------------------- | ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
5561
| commandLineArgs | "commandLineArgs": "--mysetting myvalue" | These command-line arguments for starting your app are used when launching your project in the container. |
56-
|DockerfileRunArguments|"dockerfileRunArguments": "-l mylabel=value"|Additional arguments to pass to the [docker run](https://docs.docker.com/engine/reference/commandline/run/) command. In Visual Studio 17.3 Preview 2 and later, support for replacement tokens has been added:<br/><br/> - {ProjectDir} - Full path to the project directory. <br/><br/> - {OutDir} - The value of the MSBuild property OutDir.|
62+
|DockerfileRunArguments|"dockerfileRunArguments": "-l mylabel=value"|Additional arguments to pass to the [docker run](https://docs.docker.com/engine/reference/commandline/run/) command. <br>/<br/> This setting only applies to projects that use the Dockerfile container build type. <br/><br/> In Visual Studio 17.3 and later, support for replacement tokens has been added:<br/><br/> - {ProjectDir} - Full path to the project directory. <br/><br/> - {OutDir} - The value of the MSBuild property OutDir.|
5763
| environmentVariables | "environmentVariables": {<br/> "ASPNETCORE_URLS": "https://+:443;http://+:80", <br/> "ASPNETCORE_HTTPS_PORT": "44381" <br/> } | These environment variable values are passed to the process when it is launched in the container. |
5864
| httpPort | "httpPort": 24051 | This port on the host is mapped to the container's port 80 when launching the container. |
5965
| launchBrowser | "launchBrowser": true | Indicates whether to launch the browser after successfully launching the project. |

Diff for: docs/containers/container-msbuild-properties.md

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ ms.topic: reference
99
---
1010
# Container Tools build properties
1111

12+
::: moniker range=">=vs-2022"
13+
> [!NOTE]
14+
>This article describes the MSBuild properties that apply when you choose the Dockerfile container build type. If you are using the .NET SDK build type, the customization options are different, and the information in this article is not applicable.
15+
::: moniker-end
16+
1217
You can customize how Visual Studio builds your container projects by setting the properties that MSBuild uses to build your project. For example, you can change the name of the Dockerfile, specify tags and labels for your images, provide additional arguments passed to Docker commands, and control whether Visual Studio does certain performance optimizations such as building outside of the container environment. You can also set debugging properties such as the name of the executable to launch, and the command line arguments to provide.
1318

1419
To set the value of a property, edit the project file. For example, suppose your Dockerfile is named *MyDockerfile*. You can set the `DockerfileFile` property in the project file as follows.

Diff for: docs/containers/deploy-app-service.md

-2
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,13 @@ To complete this tutorial:
3232

3333
The following steps guide you through creating a basic ASP.NET Core app that will be used in this tutorial.
3434

35-
::: moniker range=">= vs-2019"
3635
1. From the Visual Studio start window, choose **Create a new project**.
3736
1. Choose **ASP.NET Core Web App**, and choose **Next**.
3837
1. Give your new application a name (or take the default) and choose **Next**.
3938
1. Choose the .NET version you want to target. If you're not sure, choose the .NET 8.0 version.
4039
1. Choose whether or not you want SSL support by using the **Configure for HTTPS** checkbox.
4140
1. Check the **Enable Docker Support** checkbox.
4241
1. Select the container type, and click **Create**.
43-
::: moniker-end
4442

4543
## Deploy the container to Azure
4644

Diff for: docs/containers/hosting-web-apps-in-docker.md

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ ms.author: ghogen
1111
---
1212
# Deploy an ASP.NET container to a container registry using Visual Studio
1313

14-
15-
1614
Docker is a lightweight container engine, similar in some ways to a virtual machine, which you can use to host applications and services.
1715
This tutorial walks you through using Visual Studio to publish your containerized application to an [Azure Container Registry](https://azure.microsoft.com/services/container-registry).
1816

Diff for: docs/containers/overview.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Docker support is available for ASP.NET projects, ASP.NET Core projects, and .NE
4949

5050
The support for Docker in Visual Studio has changed over a number of releases in response to customer needs. There are several options to add Docker support to a project, and the supported options vary by the type of project and the version of Visual Studio. With some supported project types, if you just want a container for a single project, without using orchestration, you can do that by adding Docker support. The next level is container orchestration support, which adds appropriate support files for the particular orchestrator you choose.
5151

52-
With Visual Studio 2022 version 17.9 and later, when you add Docker support to a .NET 8 or later project, you have the option of using a Dockerfile to specify how to build the container images, or you can choose to use the built-in container support provides by the .NET SDK.
52+
With Visual Studio 2022 version 17.9 and later, when you add Docker support to a .NET 7 or later project, you have two container build types to choose from for adding Docker support. You can choose to add a Dockerfile to specify how to build the container images, or you can choose to use the built-in container support provided by the .NET SDK.
5353

5454
Also, with Visual Studio 2022 and later, when you choose container orchestration, you can use Docker Compose or Service Fabric as container orchestration services.
5555

@@ -165,7 +165,7 @@ ENTRYPOINT ["dotnet", "WebApplication-Docker.dll"]
165165

166166
## Add Docker support using the .NET SDK option
167167

168-
With Visual Studio 2022 17.9 and later, and in projects that target .NET 8 or later, you have the option of using .NET SDK's built-in support for container builds, which means you don't need a Dockerfile. Instead, settings are encoded in a `.json` configuration file, *launchSettings.json*.
168+
With Visual Studio 2022 17.9 and later, and in projects that target .NET 7 or later, you have the option of using .NET SDK's built-in support for container builds, which means you don't need a Dockerfile. Instead, settings are encoded in a `.json` configuration file, *launchSettings.json*.
169169

170170
![Screenshot showing the Container Scaffolding Options dialog for adding Docker support.](./media/overview/vs-2022/container-scaffolding-options.png)
171171

0 commit comments

Comments
 (0)