-
Notifications
You must be signed in to change notification settings - Fork 10
Create workload insertion process #302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4be4d43
cf016b5
756cfa3
46cfed9
465efcd
d7a3a59
be61d02
e90c923
e3729ca
464304c
2ad818a
1d8bdb9
67ce7f3
4f7cf15
78d6343
24040fe
6784044
de67bea
f4a3333
2a9a9fd
33526f9
0718e95
7fe5688
de46dfa
11d28fc
5c32157
1d2d21d
463689d
d722f71
e1d92ae
24e059a
efbc4ae
03686a0
ec8d8a1
81dbb7b
c78ca25
b3c0d5f
2ee6bf4
a590186
f4dbfae
b60ab43
9824c11
98ddfbb
a324f33
a246961
ed160cf
0ae3c68
026dd83
6cc0a31
ff795fd
1d933dd
958fc7a
f0bb97c
31dcfab
a6944e5
1aedc11
28540a3
96dc833
0535537
6cd9f46
20be1ae
35b0780
b32a8ee
3eac272
0addbb2
27a3de8
3b218b7
9ca2af5
ea974f5
384551e
0ac4ac9
ae5e362
6df0491
f9ea4fc
0504657
26072b6
1dd7339
e7e3e3b
d0a23d4
ac06805
62abb59
64bc345
e66a4f6
d6db026
0e39ded
3216f11
3e2d9ae
aad1ee2
3b6d882
e51a568
0f8c194
9997775
34315f4
0d5a1ce
2553bc0
41fd732
d736a8f
a13b911
beb81eb
0cd3b0c
4f52351
92f754b
8b4e504
3101c76
49f3c15
723b854
c458e17
ba5606d
28edda3
55d90c6
b285ec7
879fed1
5fb2edc
fafacfd
de72121
4d74bd4
901396b
8bf488b
e5d9896
5959f2c
5a661c5
0063c12
7355e31
7b5ddca
c1f0c45
54b267a
f94bb60
21bc89b
81aae99
0fcbe4a
4d2157b
92e88e5
b37d40b
fb26558
a895b5d
bbad4ad
7471c03
92f9ec9
f40e5d6
6607cf5
44c2a3b
9208473
b317935
0bc02d9
31b26e6
86e2076
0799e1f
ad2789c
a56dda2
3b3e492
416509c
ccbb539
b521be2
e4429d5
e80b8dc
1db531b
0fc7204
6a4cd67
3932dcc
704b647
6f880bb
3387e00
d58d5ff
aba7d75
a00e952
573de13
64a48c0
a4b87ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
## Welcome to the .NET SDK Workload Versions repo | ||
|
||
This repository contains the version information for .NET SDK Workloads. | ||
This repository contains the version information for .NET SDK Workloads. | ||
|
||
### Pre-requisites for local VS insertion build | ||
|
||
1. Install the latest [Visual Studio](https://visualstudio.microsoft.com/downloads/) with the .NET Desktop workload | ||
- Make sure to restart your PC after the installation is complete. | ||
2. [Install Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli-windows#install-or-update) | ||
3. Run `az login` to authenticate | ||
- When it asks for a subscription to select, just press Enter. The default subscription selection does not affect DARC. | ||
4. [Install DARC](https://github.com/dotnet/arcade/blob/main/Documentation/Darc.md#setting-up-your-darc-client) | ||
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) | ||
MiYanni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Use the [darc authenticate](https://github.com/dotnet/arcade/blob/main/Documentation/Darc.md#authenticate) command. | ||
- Generate the GitHub PAT [here](https://github.com/settings/tokens?type=beta). Create a fine-grained PAT instead of the classic PAT. | ||
MiYanni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Do not** create an AzDO PAT. Leave that entry blank in the darc-authenticate file for it to use local machine auth. | ||
6. Request access to the [.NET Daily Internal Build Access](https://coreidentity.microsoft.com/manage/Entitlement/entitlement/netdailyinte-q2ql) entitlement | ||
- This allows the local AzDO machine auth to gather internal assets from AzDO. | ||
- **Send a message** to one of the primary owners on the entitlement page for approval after requesting access to the entitlement. | ||
- 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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
@echo off | ||
powershell -NoLogo -NoProfile -ExecutionPolicy ByPass -Command "& """%~dp0eng\common\build.ps1""" -build -restore %*" | ||
powershell -NoLogo -NoProfile -ExecutionPolicy ByPass -Command "& """%~dp0eng\common\build.ps1""" -restore -build -msbuildEngine vs %*" | ||
MiYanni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
exit /b %ErrorLevel% |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,4 @@ | |
<PublishingVersion>3</PublishingVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<SdkAssetsToPublish Include="$(ArtifactsShippingPackagesDir)*.msi" /> | ||
<SdkAssetsToPublish Include="$(ArtifactsNonShippingPackagesDir)*.wixpack.zip" /> | ||
</ItemGroup> | ||
|
||
Comment on lines
-9
to
-13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't do anything. |
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,6 @@ | |
<InternalCertificateId Condition="'$(InternalCertificateId)' == ''">MicrosoftDotNet500</InternalCertificateId> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ItemsToSign Include="$(ArtifactsPackagesDir)**\*.msi" /> | ||
<ItemsToSign Include="$(ArtifactsPackagesDir)**\*.nupkg" /> | ||
</ItemGroup> | ||
|
||
Comment on lines
-9
to
-13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are automatically added via Arcade as part of the publish process. If they remain here, Arcade will actually fail to sign because it'll try to double sign these files. |
||
<ItemGroup> | ||
MiYanni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<ItemsToSignPostBuild Remove="*.wixpack.zip" /> | ||
</ItemGroup> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Using the downloaded workloads, this creates the VS drops to upload for VS insertion. | ||
# It builds the Microsoft.NET.Workloads.Vsman.vsmanproj per workload ZIP, which creates the appropriate VSMAN file. | ||
|
||
# $workloadPath: The path to the directory containing the workload ZIPs, usually the output path used by DARC in the download-workloads.ps1 script. | ||
# - Example Value: "$(RepoRoot)artifacts\workloads" | ||
# $msBuildToolsPath: The path to the MSBuild tools directory, generally $(MSBuildToolsPath) in MSBuild. | ||
# - Example Value: 'C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin' | ||
|
||
param ([Parameter(Mandatory=$true)] [string] $workloadPath, [Parameter(Mandatory=$true)] [string] $msBuildToolsPath) | ||
MiYanni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Extracts the workload drop zips. | ||
$workloads = Get-ChildItem $workloadPath -Include 'Workload.VSDrop.*.zip' -Recurse | ||
$workloadDropPath = (New-Item "$workloadPath\drops" -Type Container -Force).FullName | ||
$null = $workloads | ForEach-Object { Expand-Archive -Path $_.FullName -DestinationPath "$workloadDropPath\$([IO.Path]::GetFileNameWithoutExtension($_.Name))" -Force } | ||
|
||
# Extracts the workload drop metadata from the drop name and builds the .vsmanproj project. | ||
# - full: The full drop name, excluding the 'Workload.VSDrop.' prefix. | ||
# - short: The short name of the drop. Only contains the first word after 'Workload.VSDrop.'. | ||
# - type: Either 'pre.components', 'components', or 'packs'. | ||
$dropInfoRegex = '^Workload\.VSDrop\.(?<full>(?<short>\w*)\..*?(?<type>(pre\.)?components$|packs$))' | ||
$primaryVSComponentJsonValues = '' | ||
$secondaryVSComponentJsonValues = '' | ||
Get-ChildItem -Path $workloadDropPath -Directory | ForEach-Object { | ||
$null = $_.Name -match $dropInfoRegex | ||
$assemblyName = "$($Matches.full)" | ||
$dropDir = "$($_.FullName)\" | ||
|
||
# Hash the files within the drop folder to create a unique identifier that represents this workload drop. | ||
# Example: 1E3EA4FE202394037253F57436A6EAD5DE1359792B618B9072014A98563A30FB | ||
# See: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/get-filehash#example-4-compute-the-hash-of-a-string | ||
$contentStream = [System.IO.MemoryStream]::new() | ||
$writer = [System.IO.StreamWriter]::new($contentStream) | ||
$dropFiles = Get-ChildItem -Path $dropDir | Sort-Object | ||
# 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. | ||
$null = $dropFiles | Get-Content -Encoding ASCII -Raw | ForEach-Object { $writer.Write($_) } | ||
$writer.Flush() | ||
$contentStream.Position = 0 | ||
$dropHash = (Get-FileHash -InputStream $contentStream).Hash | ||
$writer.Close() | ||
|
||
$vsDropName = "Products/dotnet/workloads/$assemblyName/$dropHash" | ||
MiYanni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Reads the first line out of the .metadata file in the workload's output folder and sets it to the workload version. | ||
$workloadVersion = Get-Content "$dropDir.metadata" -First 1 | ||
# This requires building via MSBuild.exe as there are .NET Framework dependencies necessary for building the .vsmanproj. | ||
# Additionally, even using the MSBuild task won't work as '/restore' must be used for it to restore properly when building the .vsmanproj. | ||
& "$msBuildToolsPath\MSBuild.exe" Microsoft.NET.Workloads.Vsman.vsmanproj /restore /t:Build ` | ||
/p:AssemblyName=$assemblyName ` | ||
/p:VstsDropNames=$vsDropName ` | ||
/p:VsixOutputPath=$dropDir ` | ||
/p:WorkloadVersion=$workloadVersion | ||
|
||
# While in CI, set the variables necessary for uploading the VS drop. | ||
if ($env:TF_BUILD) { | ||
$shortName = "$($Matches.short)" | ||
# Remove the '.' from 'pre.components' | ||
$dropType = $Matches.type.Replace('.', '') | ||
$dropUrl = "https://vsdrop.microsoft.com/file/v1/$vsDropName;$assemblyName.vsman" | ||
|
||
Write-Host "##vso[task.setvariable variable=$($shortName)_$($dropType)_name]$vsDropName" | ||
Write-Host "##vso[task.setvariable variable=$($shortName)_$($dropType)_dir]$dropDir" | ||
Write-Host "##vso[task.setvariable variable=$($shortName)_$($dropType)_url]$dropUrl" | ||
|
||
# Each vsman file is comma-separated. First .vsman is destination and the second is source. | ||
$vsComponentValue = "$assemblyName.vsman{$workloadVersion}=$dropUrl," | ||
# All VS components are added to the primary VS component JSON string. | ||
$primaryVSComponentJsonValues += $vsComponentValue | ||
|
||
# Secondary VS components do not include (pre)components drop types. | ||
if ($dropType -ne 'components' -and $dropType -ne 'precomponents') { | ||
$secondaryVSComponentJsonValues += $vsComponentValue | ||
} | ||
} | ||
|
||
Write-Host '❗ After upload, your workload drop will be available at:' | ||
Write-Host "https://devdiv.visualstudio.com/_apps/hub/ms-vscs-artifact.build-tasks.drop-hub-group-explorer-hub?name=$vsDropName" | ||
MiYanni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
# Clean up intermediate build files in the workload drop folders. | ||
$null = Get-ChildItem -Path $workloadDropPath -Include *.json, *.vsmand, files.txt -Recurse | Remove-Item | ||
MiYanni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Write the primary and secondary component strings for the vsman files to a variable for the pipeline to use for the VS insertion step. | ||
if ($primaryVSComponentJsonValues) { | ||
# Remove the trailing comma. | ||
$primaryVSComponentJsonValues = $primaryVSComponentJsonValues -replace '.$' | ||
Write-Host "##vso[task.setvariable variable=PrimaryVSComponentJsonValues]$primaryVSComponentJsonValues" | ||
} | ||
if ($secondaryVSComponentJsonValues) { | ||
# Remove the trailing comma. | ||
$secondaryVSComponentJsonValues = $secondaryVSComponentJsonValues -replace '.$' | ||
Write-Host "##vso[task.setvariable variable=SecondaryVSComponentJsonValues]$secondaryVSComponentJsonValues" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# This downloads the workloads using DARC. | ||
# In CI, we need to pass PATs to this, so it runs in Azure Pipelines only (not through MSBuild). | ||
# For local builds, some preconfiguration is necessary. Check the README.md for details. | ||
|
||
# $workloadPath: The path to the directory as output for the workload ZIPs. This is --output-dir in the DARC command. | ||
# - Example Value: "$(RepoRoot)artifacts\workloads" | ||
# $gitHubPat: The GitHub PAT to use for DARC (CI build only). See workload-build.yml for converting the PAT to SecureString. | ||
# $azDOPat: The Azure DevOps PAT to use for DARC (CI build only). See workload-build.yml for converting the PAT to SecureString. | ||
# $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. | ||
# - See the workloadDropNames parameter in official.yml for the list generally passed to this script. | ||
# - Example Value: '{["emsdk","mono"]}' | ||
# $usePreComponents: | ||
# - If $true, includes *pre.components.zip drops and excludes *components.zip drops. | ||
# - If $false, excludes *pre.components.zip drops and includes *components.zip drops. | ||
|
||
param ([Parameter(Mandatory=$true)] [string] $workloadPath, [SecureString] $gitHubPat, [SecureString] $azDOPat, [string] $workloadListJson = '', [bool] $usePreComponents = $false) | ||
MiYanni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Local Build ### | ||
# Local build requires the installation of DARC. See: https://github.com/dotnet/arcade/blob/main/Documentation/Darc.md#setting-up-your-darc-client | ||
$darc = 'darc' | ||
$ciArguments = @() | ||
$ci = $gitHubPat -and $azDOPat | ||
|
||
### CI Build ### | ||
if ($ci) { | ||
# Darc access copied from: eng/common/post-build/publish-using-darc.ps1 | ||
$disableConfigureToolsetImport = $true | ||
. $PSScriptRoot\common\tools.ps1 | ||
|
||
$darc = Get-Darc | ||
$gitHubPatPlain = ConvertFrom-SecureString -SecureString $gitHubPat -AsPlainText | ||
$azDOPatPlain = ConvertFrom-SecureString -SecureString $azDOPat -AsPlainText | ||
$ciArguments = @( | ||
'--ci' | ||
'--github-pat' | ||
$gitHubPatPlain | ||
'--azdev-pat' | ||
$azDOPatPlain | ||
) | ||
} | ||
|
||
# Reads the Version.Details.xml file to get the workload builds. | ||
$versionDetailsPath = (Get-Item "$PSScriptRoot\Version.Details.xml").FullName | ||
$versionDetailsXml = [Xml.XmlDocument](Get-Content $versionDetailsPath) | ||
$versionDetails = $versionDetailsXml.Dependencies.ProductDependencies.Dependency | Select-Object -Property Uri, Sha -Unique | ||
|
||
# Construct the asset filter to only download the required workload drops. | ||
$workloadFilter = '' | ||
if ($workloadListJson) { | ||
$workloadList = ConvertFrom-Json -InputObject $workloadListJson | ||
if ($workloadList.Count -ne 0) { | ||
$workloadFilter = "($($workloadList | Join-String -Separator '|'))" | ||
} | ||
} | ||
# Note: The $ at the end of these filters are required for the positive/negative lookbehinds to function. | ||
# Exclude pre.components.zip. | ||
$componentFilter = '(?<!pre\.components\.zip)$' | ||
if ($usePreComponents) { | ||
# Exclude .components.zip but include pre.components.zip. | ||
$componentFilter = '((?<!\.components\.zip)|(?<=pre\.components\.zip))$' | ||
} | ||
$assetFilter = "Workload\.VSDrop\.$workloadFilter.*$componentFilter" | ||
Write-Host "assetFilter: $assetFilter" | ||
|
||
# Runs DARC against each workload build to download the drops (if applicable based on the filter). | ||
$versionDetails | ForEach-Object { | ||
$darcArguments = @( | ||
'gather-drop' | ||
'--asset-filter' | ||
$assetFilter | ||
'--repo' | ||
$_.Uri | ||
'--commit' | ||
$_.Sha | ||
'--output-dir' | ||
$workloadPath | ||
'--include-released' | ||
'--skip-existing' | ||
'--continue-on-error' | ||
'--use-azure-credential-for-blobs' | ||
) | ||
|
||
& $darc ($darcArguments + $ciArguments) | ||
} | ||
|
||
Write-Host 'Workload drops downloaded:' | ||
# https://stackoverflow.com/a/9570030/294804 | ||
Get-ChildItem $workloadPath -File -Include 'Workload.VSDrop.*.zip' -Recurse | Select-Object -Expand FullName | ||
MiYanni marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.