Placing option in the docker file vs build script 2022 to be used in container agent

Shyam Kumar 846 Reputation points
2025-05-30T05:16:23.5766667+00:00

Including optional in the below script. Please suggest way and give me updated script

in the below docker file script VS 2022 script , can you please suggest what exactly need to add?

you can refer following document

https://learn.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022

We need to install below highlighted option as optional :

Azure DevOps
0 comments No comments
{count} votes

Accepted answer
  1. Durga Reshma Malthi 4,530 Reputation points Microsoft External Staff Moderator
    2025-05-30T07:57:53.6466667+00:00

    Hi Diptesh Kumar

    Based on your screenshot of the script, the highlighted optional component is Microsoft.Net.Component.4.5.2.TargetingPack, you can insert this line at the 56th line.

    --add Microsoft.Net.Component.4.5.2.TargetingPack` ;includeOptional ` # Add this line for the optional targeting pack
    

    Based on the Visual Studio Build Tools component list for VS 2022, you will need to add the required and recommended components to your Dockerfile script.

    RUN vs_installer.exe install --quiet --norestart --wait \
        --add Microsoft.VisualStudio.Wcf.BuildTools.ComponentGroup \
        --add Microsoft.VisualStudio.Web.BuildTools.ComponentGroup \
        --add Microsoft.Net.Component.4.8.TargetingPack \
        --add Microsoft.Net.ComponentGroup.4.8.DeveloperTools \
        --add Microsoft.VisualStudio.Component.WebDeploy \
        --add Microsoft.Net.Component.3.5.DeveloperTools \
        --add Microsoft.Net.Component.4.6.2.TargetingPack \
        --add Microsoft.Net.Component.4.7.1.TargetingPack \
        --add Microsoft.Net.Component.4.7.TargetingPack \
        --add Microsoft.Net.Component.4.8.1.SDK \
        --add Microsoft.Net.Component.4.8.1.TargetingPack \
        --add Microsoft.Net.ComponentGroup.4.6.2-4.7.1.DeveloperTools \
        --add Microsoft.Net.ComponentGroup.4.8.DeveloperTools \
        --add Microsoft.NetCore.Component.Runtime.8.0 \
        --includeRecommended
    

    Alternatively,

    To ensure Microsoft.Net.Component.4.5.2.TargetingPack component is installed correctly in your Visual Studio Build Tools setup, modify your Dockerfile as follows:

    RUN vs_installer.exe install --quiet --norestart --wait \
        --add Microsoft.Net.Component.4.5.2.TargetingPack \
        --add Microsoft.Net.Component.4.8.TargetingPack \
        --add Microsoft.Net.ComponentGroup.4.8.DeveloperTools \
        --add Microsoft.VisualStudio.Component.WebDeploy \
        --add Microsoft.Net.Component.3.5.DeveloperTools \
        --includeRecommended
    

    Hope this helps!

    Please Let me know if you have any queries. If you found the information helpful, please click "Upvote" on the post to let us know and consider accepting the answer as the token of appreciation. Thank You.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Shyam Kumar 846 Reputation points
    2025-05-30T08:25:13.8733333+00:00

    Hi Durga,

    Can you respond in private message , I have follow up question


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.