Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

New build pipeline #1084

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

New build pipeline #1084

wants to merge 4 commits into from

Conversation

slluis
Copy link
Member

@slluis slluis commented Feb 17, 2022

Create new build pipeline that generates packages

@sandyarmstrong
Copy link
Member

sandyarmstrong commented Feb 26, 2022

For places where we can't use Provisionator, I've been doing the following to ensure the right macos workload version gets installed. The workloads property in global.json is made up but I think it's convenient.

Pipeline:

- task: UseDotNet@2
  displayName: 'Use .NET SDK'
  inputs:
    useGlobalJson: true
    includePreviewVersions: true

- task: PowerShell@2
  displayName: 'Provision .NET workloads'
  inputs:
    filePath: $(Build.SourcesDirectory)\build\Install-DotNetWorkload.ps1
    arguments: '-globalJsonPath $(Build.SourcesDirectory)\global.json'
    pwsh: true

global.json:

{
  "sdk": {
    "version": "6.0.200"
  },
  "workloads": {
    "microsoft.net.sdk.macos": {
      "version": "12.1.301-preview.13.4",
      "sources": [
        "https://aka.ms/dotnet6/nuget/index.json",
        "https://api.nuget.org/v3/index.json"
      ]
    }
  }
}

Install-DotNetWorkload.ps1:

param(
    [string]$globalJsonPath,
    [string]$dotnetPath = "dotnet"
)

$GlobalJson = Get-Content $globalJsonPath | ConvertFrom-Json

foreach ($workload in $GlobalJson.workloads.PSObject.Properties) {
    $workloadName = $workload.Name
    $shortWorkloadName = $workloadName.Substring($workloadName.LastIndexOf(".") + 1)
    $workloadVersion = $workload.Value.version

    Write-Host "Preparing to install workload $workloadName ($shortWorkloadName) $workloadVersion..."

    Write-Host "  Uninstalling $shortWorkloadName..."

    # TODO: This requires elevated access, at least on Mac.
    & $dotnetPath workload uninstall $shortWorkloadName

    $rollbackJson = @{}
    $rollbackJson[$workloadName] = $workloadVersion

    $rollbackFile = New-TemporaryFile
    $rollbackJson | ConvertTo-Json | Set-Content -Path $rollbackFile

    $sourcesArgs = @()
    foreach ($source in $workload.Value.sources) {
        $sourcesArgs += "--source"
        $sourcesArgs += $source
    }

    Write-Host "  Installing $shortWorkloadName..."

    # TODO: This requires elevated access, at least on Mac.
    & $dotnetPath workload install $shortWorkloadName --from-rollback-file $rollbackFile $sourcesArgs

    Remove-Item $rollbackFile
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants