Is it better to install dotnet SDK on self-hosted Azure DevOps agent, or add the UseDotNet@2 task in the build pipeline?

Viewed 832

I have configured a self-hosted Linux agent based on Ubuntu 20.04 running in a Docker container. It reports in to the agent pool and runs correctly. I'll be running the agents in AWS Fargate.

My question is whether it is considered a best practice to install the dotnet SDK in my Docker image, which will increase the size of the image considerably, or if it is better to leave it out and require build pipelines to install it via the UseDotNet@2 task, which would cause a delay every time a new agent spins up?

Is there a best practice or general guidance, and can anyone cite documentation?

Thanks!

1 Answers

I prefer UseDotNet@2 task. UseDotNet@2 task acquire a specific version of .NET Core from the Internet or the tools cache and add it to the PATH. This task can change the version of .NET Core used in subsequent tasks. Even you install dotnet SDK on the agent machine, you would also need use UseDotNet@2 task to change the version of .NET Core. And if you update the sdk on the machine, it may cause pipeline run broken. Although there may some delay when a new agent spins up, it only cause delay on the first run.

Related