0
  1. which location to add my sdk/runtime for agent to pickup and use in pipeline?
  2. Looking at https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops
  3. https://github.com/microsoft/azure-pipelines-tool-lib/blob/master/docs/overview.md#tool-cache
  4. Are these the correct resources ? how to add my own sdk?
Sai
  • 598
  • 4
  • 14

3 Answers3

1

You can use task UseDotNet@2 to set the SDK version. This task must be executed before any task that uses the SDK. For instance task, if you have the task DotNetCoreCLI@2 then UseDotNet@2 must be executed before it.

For instance below task installs the SDK version 5.0.100 if not already installed.

- task: UseDotNet@2
       displayName: 'Install .Net SDK 5.0.100, if not installed already.'
       inputs:
        packageType: sdk
        version: '5.0.100'

Classic editor

enter image description here

  • firstly we are not matured as a team to use .yml . i dont want the agent to install sdk. our security team will provide us the version and sdk/runtime files, the agent should just use it ,how can i achieve it ? – Sai Apr 16 '21 at 16:29
  • Well, the first link in your question is pointing to the yaml so, I assumed you are using yaml. These tasks can be used with classic editor too. You can find this task under the tools.I have updated my answer with a screen shot. – Ramesh Kanjinghat Apr 16 '21 at 16:38
  • does not address my problem. let me phrase my question better; lets say I have sdk/runtime files with me(in my local). I want the pipeline task to use the files I give it(i dont want the agent to do downloads from internet/elsewhere).how can I achieve this? – Sai Apr 16 '21 at 22:10
1

lets say I have sdk/runtime files with me(in my local). I want the pipeline task to use the files I give it(i dont want the agent to do downloads from internet/elsewhere).how can I achieve this?

If you want to use your local sdk/runtime, you need to use self-hosted agents in pipeline, and then configure its capabilities to add it to the PATH. Here is a similar example.

If there are multiple agents in agent pool, you could specify demands to make sure that the capabilities your pipeline needs are present on the agents that run it.

BTW, you could refer to this doc: Build, test, and deploy .NET Core apps to know more details.

Edward Han-MSFT
  • 2,879
  • 1
  • 4
  • 9
0

Ramesh provided the correct answer. You would almost always want to either use the SDK provided on the build agent, or use the UseDotNet@2 task. That being said, you may be able to use a task like PowerShell@2 and write a script that would install the SDK however it works best for you. I'd say this is atypical, though.

In answer to your question regarding the location to add your SDK, that depends on whether you have network access with permissions to access it somewhere else (i.e., not on the build agent nor in your source code). If so, you could put it in an AWS S3 bucket, for example. Otherwise, you could include it in your repository and reference it that way -- this is generally not great if the file is large.

Kyle K
  • 163
  • 1
  • 8