Skip to content

Commit 77aac23

Browse files
authored
Merge pull request #302 from dotnet/feature/workload-publish-main2
2 parents c8532fb + a4b87ac commit 77aac23

18 files changed

+547
-236
lines changed

Directory.Build.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
<Copyright>$(CopyrightNetFoundation)</Copyright>
88
<PackageLicenseExpression>MIT</PackageLicenseExpression>
99
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
10-
<!-- <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
11-
<DebugType>embedded</DebugType>
12-
<DebugSymbols>true</DebugSymbols> -->
1310
<LangVersion>Latest</LangVersion>
11+
<NoSwixBuildPlugin>true</NoSwixBuildPlugin>
12+
<!-- See: https://dev.azure.com/devdiv/DevDiv/_wiki/wikis/DevDiv.wiki/29608/How-to-Build-a-vsman-file?anchor=creating-your-.vsman-file -->
13+
<GetBuildVersionTargetDefined>true</GetBuildVersionTargetDefined>
1414
</PropertyGroup>
1515

1616
</Project>

Directory.Build.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
<!-- Need to update the workloads version after the arcade targets have run -->
77
<WorkloadsVersion Condition="'$(VersionSuffix)' != ''">$(WorkloadsVersion)-$(VersionSuffix)</WorkloadsVersion>
88
</PropertyGroup>
9+
910
</Project>

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
11
## Welcome to the .NET SDK Workload Versions repo
22

3-
This repository contains the version information for .NET SDK Workloads.
3+
This repository contains the version information for .NET SDK Workloads.
4+
5+
### Pre-requisites for local VS insertion build
6+
7+
1. Install the latest [Visual Studio](https://visualstudio.microsoft.com/downloads/) with the .NET Desktop workload
8+
- Make sure to restart your PC after the installation is complete.
9+
2. [Install Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli-windows#install-or-update)
10+
3. Run `az login` to authenticate
11+
- When it asks for a subscription to select, just press Enter. The default subscription selection does not affect DARC.
12+
4. [Install DARC](https://github.com/dotnet/arcade/blob/main/Documentation/Darc.md#setting-up-your-darc-client)
13+
5. [Add GitHub auth for DARC](https://github.com/dotnet/arcade/blob/main/Documentation/Darc.md#step-3-set-additional-pats-for-azure-devops-and-github-operations)
14+
- Use the [darc authenticate](https://github.com/dotnet/arcade/blob/main/Documentation/Darc.md#authenticate) command.
15+
- Generate the GitHub PAT [here](https://github.com/settings/tokens?type=beta). Create a fine-grained PAT instead of the classic PAT.
16+
- **Do not** create an AzDO PAT. Leave that entry blank in the darc-authenticate file for it to use local machine auth.
17+
6. Request access to the [.NET Daily Internal Build Access](https://coreidentity.microsoft.com/manage/Entitlement/entitlement/netdailyinte-q2ql) entitlement
18+
- This allows the local AzDO machine auth to gather internal assets from AzDO.
19+
- **Send a message** to one of the primary owners on the entitlement page for approval after requesting access to the entitlement.
20+
- Should take about 20 mins for the entitlement process to complete (will appear on your [entitlements list](https://coreidentity.microsoft.com/manage/entitlement)) and another 30 mins the access to propagate to DARC. Basically, after approval, wait an hour until you actually attempt to build.

build.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@echo off
2-
powershell -NoLogo -NoProfile -ExecutionPolicy ByPass -Command "& """%~dp0eng\common\build.ps1""" -build -restore %*"
2+
powershell -NoLogo -NoProfile -ExecutionPolicy ByPass -Command "& """%~dp0eng\common\build.ps1""" -restore -build -msbuildEngine vs %*"
33
exit /b %ErrorLevel%

eng/Publishing.props

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,4 @@
66
<PublishingVersion>3</PublishingVersion>
77
</PropertyGroup>
88

9-
<ItemGroup>
10-
<SdkAssetsToPublish Include="$(ArtifactsShippingPackagesDir)*.msi" />
11-
<SdkAssetsToPublish Include="$(ArtifactsNonShippingPackagesDir)*.wixpack.zip" />
12-
</ItemGroup>
13-
149
</Project>

eng/Signing.props

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
<InternalCertificateId Condition="'$(InternalCertificateId)' == ''">MicrosoftDotNet500</InternalCertificateId>
77
</PropertyGroup>
88

9-
<ItemGroup>
10-
<ItemsToSign Include="$(ArtifactsPackagesDir)**\*.msi" />
11-
<ItemsToSign Include="$(ArtifactsPackagesDir)**\*.nupkg" />
12-
</ItemGroup>
13-
149
<ItemGroup>
1510
<ItemsToSignPostBuild Remove="*.wixpack.zip" />
1611
</ItemGroup>

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
</PropertyGroup>
5757
<PropertyGroup>
5858
<WixPackageVersion>3.14.0-8606.20240208.1</WixPackageVersion>
59-
<SwixPackageVersion>1.1.87-gba258badda</SwixPackageVersion>
59+
<SwixPackageVersion>1.1.392</SwixPackageVersion>
6060
</PropertyGroup>
6161
<PropertyGroup Label="EmscriptenWorkloads">
6262
<!-- Workloads from dotnet/emsdk -->

eng/create-workload-drops.ps1

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Using the downloaded workloads, this creates the VS drops to upload for VS insertion.
2+
# It builds the Microsoft.NET.Workloads.Vsman.vsmanproj per workload ZIP, which creates the appropriate VSMAN file.
3+
4+
# $workloadPath: The path to the directory containing the workload ZIPs, usually the output path used by DARC in the download-workloads.ps1 script.
5+
# - Example Value: "$(RepoRoot)artifacts\workloads"
6+
# $msBuildToolsPath: The path to the MSBuild tools directory, generally $(MSBuildToolsPath) in MSBuild.
7+
# - Example Value: 'C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin'
8+
9+
param ([Parameter(Mandatory=$true)] [string] $workloadPath, [Parameter(Mandatory=$true)] [string] $msBuildToolsPath)
10+
11+
# Extracts the workload drop zips.
12+
$workloads = Get-ChildItem $workloadPath -Include 'Workload.VSDrop.*.zip' -Recurse
13+
$workloadDropPath = (New-Item "$workloadPath\drops" -Type Container -Force).FullName
14+
$null = $workloads | ForEach-Object { Expand-Archive -Path $_.FullName -DestinationPath "$workloadDropPath\$([IO.Path]::GetFileNameWithoutExtension($_.Name))" -Force }
15+
16+
# Extracts the workload drop metadata from the drop name and builds the .vsmanproj project.
17+
# - full: The full drop name, excluding the 'Workload.VSDrop.' prefix.
18+
# - short: The short name of the drop. Only contains the first word after 'Workload.VSDrop.'.
19+
# - type: Either 'pre.components', 'components', or 'packs'.
20+
$dropInfoRegex = '^Workload\.VSDrop\.(?<full>(?<short>\w*)\..*?(?<type>(pre\.)?components$|packs$))'
21+
$primaryVSComponentJsonValues = ''
22+
$secondaryVSComponentJsonValues = ''
23+
Get-ChildItem -Path $workloadDropPath -Directory | ForEach-Object {
24+
$null = $_.Name -match $dropInfoRegex
25+
$assemblyName = "$($Matches.full)"
26+
$dropDir = "$($_.FullName)\"
27+
28+
# Hash the files within the drop folder to create a unique identifier that represents this workload drop.
29+
# Example: 1E3EA4FE202394037253F57436A6EAD5DE1359792B618B9072014A98563A30FB
30+
# See: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/get-filehash#example-4-compute-the-hash-of-a-string
31+
$contentStream = [System.IO.MemoryStream]::new()
32+
$writer = [System.IO.StreamWriter]::new($contentStream)
33+
$dropFiles = Get-ChildItem -Path $dropDir | Sort-Object
34+
# Note: We're using ASCII because when testing between PS 5.1 and PS 7.5, this would result in the same hash. Other encodings arrived at different hashes.
35+
$null = $dropFiles | Get-Content -Encoding ASCII -Raw | ForEach-Object { $writer.Write($_) }
36+
$writer.Flush()
37+
$contentStream.Position = 0
38+
$dropHash = (Get-FileHash -InputStream $contentStream).Hash
39+
$writer.Close()
40+
41+
$vsDropName = "Products/dotnet/workloads/$assemblyName/$dropHash"
42+
# Reads the first line out of the .metadata file in the workload's output folder and sets it to the workload version.
43+
$workloadVersion = Get-Content "$dropDir.metadata" -First 1
44+
# This requires building via MSBuild.exe as there are .NET Framework dependencies necessary for building the .vsmanproj.
45+
# Additionally, even using the MSBuild task won't work as '/restore' must be used for it to restore properly when building the .vsmanproj.
46+
& "$msBuildToolsPath\MSBuild.exe" Microsoft.NET.Workloads.Vsman.vsmanproj /restore /t:Build `
47+
/p:AssemblyName=$assemblyName `
48+
/p:VstsDropNames=$vsDropName `
49+
/p:VsixOutputPath=$dropDir `
50+
/p:WorkloadVersion=$workloadVersion
51+
52+
# While in CI, set the variables necessary for uploading the VS drop.
53+
if ($env:TF_BUILD) {
54+
$shortName = "$($Matches.short)"
55+
# Remove the '.' from 'pre.components'
56+
$dropType = $Matches.type.Replace('.', '')
57+
$dropUrl = "https://vsdrop.microsoft.com/file/v1/$vsDropName;$assemblyName.vsman"
58+
59+
Write-Host "##vso[task.setvariable variable=$($shortName)_$($dropType)_name]$vsDropName"
60+
Write-Host "##vso[task.setvariable variable=$($shortName)_$($dropType)_dir]$dropDir"
61+
Write-Host "##vso[task.setvariable variable=$($shortName)_$($dropType)_url]$dropUrl"
62+
63+
# Each vsman file is comma-separated. First .vsman is destination and the second is source.
64+
$vsComponentValue = "$assemblyName.vsman{$workloadVersion}=$dropUrl,"
65+
# All VS components are added to the primary VS component JSON string.
66+
$primaryVSComponentJsonValues += $vsComponentValue
67+
68+
# Secondary VS components do not include (pre)components drop types.
69+
if ($dropType -ne 'components' -and $dropType -ne 'precomponents') {
70+
$secondaryVSComponentJsonValues += $vsComponentValue
71+
}
72+
}
73+
74+
Write-Host '❗ After upload, your workload drop will be available at:'
75+
Write-Host "https://devdiv.visualstudio.com/_apps/hub/ms-vscs-artifact.build-tasks.drop-hub-group-explorer-hub?name=$vsDropName"
76+
}
77+
78+
# Clean up intermediate build files in the workload drop folders.
79+
$null = Get-ChildItem -Path $workloadDropPath -Include *.json, *.vsmand, files.txt -Recurse | Remove-Item
80+
81+
# Write the primary and secondary component strings for the vsman files to a variable for the pipeline to use for the VS insertion step.
82+
if ($primaryVSComponentJsonValues) {
83+
# Remove the trailing comma.
84+
$primaryVSComponentJsonValues = $primaryVSComponentJsonValues -replace '.$'
85+
Write-Host "##vso[task.setvariable variable=PrimaryVSComponentJsonValues]$primaryVSComponentJsonValues"
86+
}
87+
if ($secondaryVSComponentJsonValues) {
88+
# Remove the trailing comma.
89+
$secondaryVSComponentJsonValues = $secondaryVSComponentJsonValues -replace '.$'
90+
Write-Host "##vso[task.setvariable variable=SecondaryVSComponentJsonValues]$secondaryVSComponentJsonValues"
91+
}

eng/download-workloads.ps1

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# This downloads the workloads using DARC.
2+
# In CI, we need to pass PATs to this, so it runs in Azure Pipelines only (not through MSBuild).
3+
# For local builds, some preconfiguration is necessary. Check the README.md for details.
4+
5+
# $workloadPath: The path to the directory as output for the workload ZIPs. This is --output-dir in the DARC command.
6+
# - Example Value: "$(RepoRoot)artifacts\workloads"
7+
# $gitHubPat: The GitHub PAT to use for DARC (CI build only). See workload-build.yml for converting the PAT to SecureString.
8+
# $azDOPat: The Azure DevOps PAT to use for DARC (CI build only). See workload-build.yml for converting the PAT to SecureString.
9+
# $workloadListJson: The JSON string of the list of workload drop names to download. If not provided, all workloads found in Version.Details.xml will be downloaded.
10+
# - See the workloadDropNames parameter in official.yml for the list generally passed to this script.
11+
# - Example Value: '{["emsdk","mono"]}'
12+
# $usePreComponents:
13+
# - If $true, includes *pre.components.zip drops and excludes *components.zip drops.
14+
# - If $false, excludes *pre.components.zip drops and includes *components.zip drops.
15+
16+
param ([Parameter(Mandatory=$true)] [string] $workloadPath, [SecureString] $gitHubPat, [SecureString] $azDOPat, [string] $workloadListJson = '', [bool] $usePreComponents = $false)
17+
18+
### Local Build ###
19+
# Local build requires the installation of DARC. See: https://github.com/dotnet/arcade/blob/main/Documentation/Darc.md#setting-up-your-darc-client
20+
$darc = 'darc'
21+
$ciArguments = @()
22+
$ci = $gitHubPat -and $azDOPat
23+
24+
### CI Build ###
25+
if ($ci) {
26+
# Darc access copied from: eng/common/post-build/publish-using-darc.ps1
27+
$disableConfigureToolsetImport = $true
28+
. $PSScriptRoot\common\tools.ps1
29+
30+
$darc = Get-Darc
31+
$gitHubPatPlain = ConvertFrom-SecureString -SecureString $gitHubPat -AsPlainText
32+
$azDOPatPlain = ConvertFrom-SecureString -SecureString $azDOPat -AsPlainText
33+
$ciArguments = @(
34+
'--ci'
35+
'--github-pat'
36+
$gitHubPatPlain
37+
'--azdev-pat'
38+
$azDOPatPlain
39+
)
40+
}
41+
42+
# Reads the Version.Details.xml file to get the workload builds.
43+
$versionDetailsPath = (Get-Item "$PSScriptRoot\Version.Details.xml").FullName
44+
$versionDetailsXml = [Xml.XmlDocument](Get-Content $versionDetailsPath)
45+
$versionDetails = $versionDetailsXml.Dependencies.ProductDependencies.Dependency | Select-Object -Property Uri, Sha -Unique
46+
47+
# Construct the asset filter to only download the required workload drops.
48+
$workloadFilter = ''
49+
if ($workloadListJson) {
50+
$workloadList = ConvertFrom-Json -InputObject $workloadListJson
51+
if ($workloadList.Count -ne 0) {
52+
$workloadFilter = "($($workloadList | Join-String -Separator '|'))"
53+
}
54+
}
55+
# Note: The $ at the end of these filters are required for the positive/negative lookbehinds to function.
56+
# Exclude pre.components.zip.
57+
$componentFilter = '(?<!pre\.components\.zip)$'
58+
if ($usePreComponents) {
59+
# Exclude .components.zip but include pre.components.zip.
60+
$componentFilter = '((?<!\.components\.zip)|(?<=pre\.components\.zip))$'
61+
}
62+
$assetFilter = "Workload\.VSDrop\.$workloadFilter.*$componentFilter"
63+
Write-Host "assetFilter: $assetFilter"
64+
65+
# Runs DARC against each workload build to download the drops (if applicable based on the filter).
66+
$versionDetails | ForEach-Object {
67+
$darcArguments = @(
68+
'gather-drop'
69+
'--asset-filter'
70+
$assetFilter
71+
'--repo'
72+
$_.Uri
73+
'--commit'
74+
$_.Sha
75+
'--output-dir'
76+
$workloadPath
77+
'--include-released'
78+
'--skip-existing'
79+
'--continue-on-error'
80+
'--use-azure-credential-for-blobs'
81+
)
82+
83+
& $darc ($darcArguments + $ciArguments)
84+
}
85+
86+
Write-Host 'Workload drops downloaded:'
87+
# https://stackoverflow.com/a/9570030/294804
88+
Get-ChildItem $workloadPath -File -Include 'Workload.VSDrop.*.zip' -Recurse | Select-Object -Expand FullName

0 commit comments

Comments
 (0)