Skip to content

Commit 0c6cecf

Browse files
authored
pathupdates (#8616)
1 parent 0efae4e commit 0c6cecf

File tree

1 file changed

+66
-3
lines changed

1 file changed

+66
-3
lines changed

docs/install/build-tools-container.md

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Save the following example Dockerfile to a new file on your disk. If the file is
9999
100100
::: moniker-end
101101

102-
::: moniker range=">=vs-2019"
102+
::: moniker range="vs-2019"
103103

104104
```dockerfile
105105
# escape=`
@@ -143,6 +143,49 @@ Save the following example Dockerfile to a new file on your disk. If the file is
143143
144144
::: moniker-end
145145

146+
::: moniker range=">=vs-2022"
147+
148+
```dockerfile
149+
# escape=`
150+
151+
# Use the latest Windows Server Core image with .NET Framework 4.8.
152+
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019
153+
154+
# Restore the default Windows shell for correct batch processing.
155+
SHELL ["cmd", "/S", "/C"]
156+
157+
RUN `
158+
# Download the Build Tools bootstrapper.
159+
curl -SL --output vs_buildtools.exe https://aka.ms/vs/17/pre/vs_buildtools.exe `
160+
`
161+
# Install Build Tools with the Microsoft.VisualStudio.Workload.AzureBuildTools workload, excluding workloads and components with known issues.
162+
&& (start /w vs_buildtools.exe --quiet --wait --norestart --nocache modify `
163+
--installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools" `
164+
--add Microsoft.VisualStudio.Workload.AzureBuildTools `
165+
--remove Microsoft.VisualStudio.Component.Windows10SDK.10240 `
166+
--remove Microsoft.VisualStudio.Component.Windows10SDK.10586 `
167+
--remove Microsoft.VisualStudio.Component.Windows10SDK.14393 `
168+
--remove Microsoft.VisualStudio.Component.Windows81SDK `
169+
|| IF "%ERRORLEVEL%"=="3010" EXIT 0) `
170+
`
171+
# Cleanup
172+
&& del /q vs_buildtools.exe
173+
174+
# Define the entry point for the docker container.
175+
# This entry point starts the developer command prompt and launches the PowerShell shell.
176+
ENTRYPOINT ["C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
177+
```
178+
179+
> [!TIP]
180+
> For a list of workloads and components, see the [Visual Studio Build Tools component directory](workload-component-id-vs-build-tools.md).
181+
>
182+
183+
> [!WARNING]
184+
> If you base your image directly on microsoft/windowsservercore, the .NET Framework might not install properly and no install error is indicated. Managed code might not run after the install is complete. Instead, base your image on [microsoft/dotnet-framework:4.8](https://hub.docker.com/r/microsoft/dotnet-framework) or later. Also note that images that are tagged version 4.8 or later might use PowerShell as the default `SHELL`, which will cause the `RUN` and `ENTRYPOINT` instructions to fail.
185+
>
186+
> See [Windows container version compatibility](/virtualization/windowscontainers/deploy-containers/version-compatibility) to see which container OS versions are supported on which host OS versions, and [Known issues for containers](build-tools-container-issues.md) for known issues.
187+
188+
::: moniker-end
146189
> [!NOTE]
147190
> Error code `3010` is used to indicate success with a reboot required, see [MsiExec.exe error messages](/windows/win32/msi/error-codes) for more information.
148191
@@ -160,7 +203,7 @@ Save the following example Dockerfile to a new file on your disk. If the file is
160203

161204
::: moniker-end
162205

163-
::: moniker range=">=vs-2019"
206+
::: moniker range="vs-2019"
164207

165208
```shell
166209
docker build -t buildtools2019:latest -m 2GB .
@@ -172,6 +215,18 @@ Save the following example Dockerfile to a new file on your disk. If the file is
172215

173216
::: moniker-end
174217

218+
::: moniker range=">=vs-2022"
219+
220+
```shell
221+
docker build -t buildtools:latest -m 2GB .
222+
```
223+
224+
This command builds the Dockerfile in the current directory using 2 GB of memory. The default 1 GB is not sufficient when some workloads are installed; however, you might be able to build with only 1 GB of memory depending on your build requirements.
225+
226+
The final image is tagged "buildtools:latest" so you can easily run it in a container as "buildtools" since the "latest" tag is the default if no tag is specified. If you want to use a specific version of Visual Studio Build Tools in a more [advanced scenario](advanced-build-tools-container.md), you might instead tag the container with a specific Visual Studio build number as well as "latest" so containers can use a specific version consistently.
227+
228+
::: moniker-end
229+
175230
## Using the built image
176231

177232
Now that you have created an image, you can run it in a container to do both interactive and automated builds. The example uses the Developer Command Prompt, so your PATH and other environment variables are already configured.
@@ -188,14 +243,22 @@ Now that you have created an image, you can run it in a container to do both int
188243

189244
::: moniker-end
190245

191-
::: moniker range=">=vs-2019"
246+
::: moniker range="vs-2019"
192247

193248
```shell
194249
docker run -it buildtools2019
195250
```
196251

197252
::: moniker-end
198253

254+
::: moniker range=">=vs-2022"
255+
256+
```shell
257+
docker run -it buildtools
258+
```
259+
260+
::: moniker-end
261+
199262
To use this image for your CI/CD workflow, you can publish it to your own [Azure Container Registry](https://azure.microsoft.com/services/container-registry) or other internal [Docker registry](https://docs.docker.com/registry/deploying) so servers need only to pull it.
200263

201264
> [!NOTE]

0 commit comments

Comments
 (0)