Skip to content

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

Merged
merged 168 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
168 commits
Select commit Hold shift + click to select a range
4be4d43
Added basic pipeline to do workload set publishing. Added initial scr…
MiYanni Jul 22, 2024
cf016b5
Realized I don't want to make a new AzDO pipeline yet. So, reusing th…
MiYanni Jul 22, 2024
756cfa3
Fix calling the darc command over the version details.
MiYanni Jul 22, 2024
46cfed9
Fixed tools path. Clean up commented script.
MiYanni Jul 22, 2024
465efcd
Added logic to move the workloads into a drops folder.
MiYanni Jul 22, 2024
d7a3a59
Clean up commented out scripting. Prep prior to drop creation work.
MiYanni Jul 23, 2024
be61d02
Passing in PAT information into the gather-drop script.
MiYanni Jul 23, 2024
e90c923
Forgot to comment out parameters node.
MiYanni Jul 23, 2024
e3729ca
Add asset-filter to gather-drop.
MiYanni Jul 23, 2024
464304c
Convert the script parameters to secure strings.
MiYanni Jul 24, 2024
2ad818a
Forgot the additional arguments for ConvertTo-SecureString. Added Con…
MiYanni Jul 24, 2024
1d8bdb9
Consolidate ConvertFrom-SecureString. Fixed --output-dir.
MiYanni Jul 24, 2024
67ce7f3
Extract the workload packages into the drops directory.
MiYanni Jul 24, 2024
4f7cf15
In-progress determining how to use the Vsman SDK to build the vsman f…
MiYanni Aug 26, 2024
78d6343
Trying to update the SwixBuild version so that the Vsman stuff will b…
MiYanni Aug 28, 2024
24040fe
Got the build to work from build.cmd via the xcopy-msbuild tool versi…
MiYanni Aug 29, 2024
6784044
Progress on making a multi-build vsman target for each drop folder.
MiYanni Sep 25, 2024
de67bea
Made each workload use the drop folder as their output for creating t…
MiYanni Sep 30, 2024
f4a3333
Trying parameter use for dynamic variable access.
MiYanni Sep 30, 2024
2a9a9fd
Temporarily comment out other feeds because those feeds potentially c…
MiYanni Sep 30, 2024
33526f9
In-progress having the drop acquisition process being able to work lo…
MiYanni Oct 1, 2024
0718e95
Continued in-progress of enabling local drop download processing.
MiYanni Oct 1, 2024
7fe5688
Got the local build process for VSMAN files working.
MiYanni Oct 2, 2024
de46dfa
Merge branch 'release/8.0.4xx' into feature/workload-publish
MiYanni Oct 2, 2024
11d28fc
In-progress of getting the workload info spit out to the pipeline for…
MiYanni Oct 2, 2024
5c32157
Moved all the logic for doing the build to the download-workloads.ps1…
MiYanni Oct 3, 2024
1d2d21d
Using the 1ES task for creating a drop.
MiYanni Oct 3, 2024
463689d
Missed a slash in file path. Updated VSDrop task display name.
MiYanni Oct 3, 2024
d722f71
Using plain pats for testing the built.
MiYanni Oct 3, 2024
e1d92ae
Trying a different image pool for CI.
MiYanni Oct 3, 2024
24e059a
Split workload download and drop creation into 2 scripts. That way, P…
MiYanni Oct 4, 2024
efbc4ae
Used incorrect PAT name.
MiYanni Oct 4, 2024
03686a0
Adjusted the download script to provide the darc arguments as a string.
MiYanni Oct 4, 2024
ec8d8a1
Moved the string arguments into the loop so the loop variable is valid.
MiYanni Oct 4, 2024
81dbb7b
Trying to do the darc arguments as a single string line.
MiYanni Oct 4, 2024
c78ca25
Using lists as the argument mechanism to pass to darc.
MiYanni Oct 4, 2024
b3c0d5f
Updated the package version for Vsman because that is what is availab…
MiYanni Oct 4, 2024
2ee6bf4
Cleaned up comments in scripts. Added back downloading drops locally.
MiYanni Oct 4, 2024
a590186
Trying default settings for VSTS drop task.
MiYanni Oct 6, 2024
f4dbfae
Added proper access to the DevDiv drop service.
MiYanni Oct 6, 2024
b60ab43
Clean up defaulted value parameters.
MiYanni Oct 6, 2024
9824c11
Added process for creating componentJsonValues. This allowed me to ad…
MiYanni Oct 6, 2024
98ddfbb
Trying to see if putting the name of the PAT as the PatAuthEnvVar works.
MiYanni Oct 7, 2024
a324f33
Removing accessToken, just to see what happens.
MiYanni Oct 7, 2024
a246961
Back to using the token again. It is definitely the right token.
MiYanni Oct 7, 2024
ed160cf
Increase the timeout time for the build stage.
MiYanni Oct 7, 2024
0ae3c68
Trying an older version of the insertion task.
MiYanni Oct 11, 2024
026dd83
Used the existing DevDiv PAT for the insertion task.
MiYanni Oct 11, 2024
6cc0a31
Removing aspire from Version.Details.xml. Removing downloading pre.co…
MiYanni Oct 29, 2024
ff795fd
Added logic for handling multitarget. Added logic for mutually exclus…
MiYanni Nov 1, 2024
1d933dd
Added logic for handling primary and secondary insertion concepts.
MiYanni Nov 1, 2024
958fc7a
Merge branch 'release/8.0.4xx' into feature/workload-publish
MiYanni Nov 1, 2024
f0bb97c
Added missing dollar sign for boolean parameter.
MiYanni Nov 2, 2024
31dcfab
Moved the preview components checkbox up.
MiYanni Nov 4, 2024
a6944e5
Added ability to read the drop version number out of the .metadata fi…
MiYanni Nov 8, 2024
1aedc11
Added algorithm for hashing a drop folder.
MiYanni Nov 12, 2024
28540a3
Added the file hash logic to create-workload-drops.ps1.
MiYanni Nov 16, 2024
96dc833
Merge branch 'release/8.0.4xx' into feature/workload-publish
MiYanni Nov 16, 2024
0535537
Merge branch 'main' into feature/workload-publish-main
MiYanni Nov 16, 2024
6cd9f46
Merge branch 'main' into feature/workload-publish-main
MiYanni Nov 16, 2024
20be1ae
Trying to use a newer version of the Android workload to see if it wo…
MiYanni Nov 25, 2024
35b0780
Added android to the workloads list. Updated android workload version.
MiYanni Nov 26, 2024
b32a8ee
Merge branch 'main' into feature/workload-publish-main
MiYanni Dec 6, 2024
3eac272
Changed build pool to windows.vs2022.amd64.
MiYanni Dec 9, 2024
0addbb2
Changed build pool to 1es-windows-2022.
MiYanni Dec 9, 2024
27a3de8
Added publishing the binlog.
MiYanni Dec 9, 2024
3b218b7
Publish all artifacts.
MiYanni Dec 9, 2024
9ca2af5
Try changing the dotnet version.
MiYanni Dec 9, 2024
ea974f5
Add workaround for broken path searching for Arcade .NET Framework lo…
MiYanni Dec 9, 2024
384551e
Fix broken tools files.
MiYanni Dec 9, 2024
0ac4ac9
Add publishing workload drops. Update default branches for insertions.
MiYanni Dec 10, 2024
ae5e362
Added the ability to check if the VS Drop is already published or not.
MiYanni Dec 10, 2024
6df0491
Using a different means to check if the VS drop exists.
MiYanni Dec 11, 2024
f9ea4fc
Consolidating the workload upload check.
MiYanni Dec 11, 2024
0504657
Changed tokens for checking VS Drop and insertion PR creation.
MiYanni Dec 11, 2024
26072b6
Trying the DotNetRelease-PME service connection for creating the VS i…
MiYanni Dec 16, 2024
1dd7339
Merge branch 'feature/workload-publish-main' of https://dnceng.visual…
MiYanni Dec 16, 2024
e7e3e3b
Trying infra tokens from the fsharp insertion process.
MiYanni Dec 16, 2024
d0a23d4
Try using the MicroBuildTemplate.
MiYanni Dec 16, 2024
ac06805
Changed the base drop url to https://vsdrop.corp.microsoft.com/file/v1
MiYanni Dec 16, 2024
62abb59
Set the version information inside the component parameter expression…
MiYanni Dec 17, 2024
64bc345
Added purple circle to stages, jobs, and steps defined in this repo.
MiYanni Dec 17, 2024
e66a4f6
Show environment variables.
MiYanni Dec 17, 2024
d6db026
Added dropexe acquisition. Added InsertionTopicBranch logic.
MiYanni Dec 17, 2024
0e39ded
Trying different expression for pipeline.startTime.
MiYanni Dec 17, 2024
3216f11
Trying different expression for pipeline.startTime. Forgot the other …
MiYanni Dec 17, 2024
3e2d9ae
Trying to figure out why I couldn't get the drop dir.
MiYanni Dec 17, 2024
aad1ee2
Added ability to set VS topic branch manually. More debugging for dro…
MiYanni Dec 17, 2024
3b6d882
Incorrect indentation.
MiYanni Dec 17, 2024
e51a568
Minor cleanup.
MiYanni Dec 17, 2024
0f8c194
Temporarily use different pool.
MiYanni Dec 17, 2024
9997775
Moved the drop exe stuff to preSteps. Added general logic for using d…
MiYanni Dec 17, 2024
34315f4
Fix powershell script to be multiline via vertical bar instead of arrow.
MiYanni Dec 17, 2024
0d5a1ce
Still trying to get drop exe info.
MiYanni Dec 17, 2024
2553bc0
The folders are hidden. Added -Force so hidden things are included.
MiYanni Dec 17, 2024
41fd732
Try against the _tasks folder.
MiYanni Dec 18, 2024
d736a8f
Show task hierarchy.
MiYanni Dec 18, 2024
a13b911
Added -Force to every Get-ChildItem call.
MiYanni Dec 18, 2024
beb81eb
Publish the version folder for drop stuff.
MiYanni Dec 18, 2024
0cd3b0c
Added drop check logic.
MiYanni Dec 18, 2024
4f52351
Testing how failed list calls react.
MiYanni Dec 18, 2024
92f754b
Cleaned up testing VS drop logic. Added ability to change it in pipel…
MiYanni Dec 18, 2024
8b4e504
Remove unused parameter.
MiYanni Dec 18, 2024
3101c76
Fix task folder lookup.
MiYanni Dec 18, 2024
49f3c15
Cleaned up drop checking script. Should work once I'm able to run a f…
MiYanni Dec 18, 2024
723b854
Removed drop test parameter.
MiYanni Dec 19, 2024
c458e17
Trying empty string as default topic branch id.
MiYanni Dec 19, 2024
ba5606d
Made a sentinel value of |default|.
MiYanni Dec 19, 2024
28edda3
See if the publish task works properly.
MiYanni Jan 6, 2025
55d90c6
Added missing BuildConfiguration, which is required by Arcade.
MiYanni Jan 7, 2025
b285ec7
Added missing build args.
MiYanni Jan 7, 2025
879fed1
Change to _BuildConfig.
MiYanni Jan 7, 2025
5fb2edc
Remove version workaround. Add in logic to replace plugin.ps1 with lo…
MiYanni Jan 7, 2025
fafacfd
Trying UTF8 for access token instead of ASCII.
MiYanni Jan 8, 2025
de72121
Trying Bearer auth. Added |temp| value for topic branch name.
MiYanni Jan 8, 2025
4d74bd4
Added missing build flags for CI building.
MiYanni Jan 8, 2025
901396b
Fix broken |temp| topic branch name.
MiYanni Jan 8, 2025
8bf488b
Shorten |temp| topic branch name. Attempt to use UseDefaultCredential…
MiYanni Jan 8, 2025
e5d9896
Trying to set Credentials via NetworkCredential.
MiYanni Jan 8, 2025
5959f2c
Trying to set Credentials via PSCredential.
MiYanni Jan 8, 2025
5a661c5
Trying empty string for PSCredential username.
MiYanni Jan 8, 2025
0063c12
Made username PAT.
MiYanni Jan 8, 2025
7355e31
Explicitly set system.accesstoken environment variable. Trying differ…
MiYanni Jan 9, 2025
7b5ddca
Trying different PAT.
MiYanni Jan 9, 2025
c1f0c45
Cleanup of commented code in official.yml.
MiYanni Jan 10, 2025
54b267a
Remove custom logic for checking if drop exists remotely. Trying to r…
MiYanni Jan 10, 2025
f94bb60
Changed the way the build is started.
MiYanni Jan 10, 2025
21bc89b
Trying different insertion PAT for now.
MiYanni Jan 10, 2025
81aae99
Forgot to set msbuildEngine to vs.
MiYanni Jan 10, 2025
0fcbe4a
Trying only release pipeline PATs. Minor cleanup of other extraneous …
MiYanni Jan 10, 2025
4d2157b
Pass the workload drop list to the download-workloads.ps1 script.
MiYanni Jan 10, 2025
92e88e5
Fix broken workload list script. Use MicroBuildInsertionVS service co…
MiYanni Jan 10, 2025
b37d40b
Hope the json passes properly now.
MiYanni Jan 10, 2025
fb26558
Trying to add back PostBuildSign to see if signing continues to have …
MiYanni Jan 10, 2025
a895b5d
Adding the log folder to always be published to the artifacts.
MiYanni Jan 10, 2025
bbad4ad
Commenting out ItemsToSign.
MiYanni Jan 10, 2025
7471c03
Switched from the jobs.yml template to the job.yml template.
MiYanni Jan 10, 2025
92f9ec9
Using prior token for VS drop access.
MiYanni Jan 10, 2025
f40e5d6
Continuing cleanup.
MiYanni Jan 10, 2025
6607cf5
Go back to jobs.yml so the Publish Assets job exists again.
MiYanni Jan 10, 2025
44c2a3b
Provided the access token that should (hopefully) get used for clonin…
MiYanni Jan 10, 2025
9208473
Added workload insertion template. Stopped hotswapping plugin.ps1 files.
MiYanni Jan 11, 2025
b317935
Trying to pass in the service name.
MiYanni Jan 11, 2025
0bc02d9
Not passing in service name. Added the env access token back.
MiYanni Jan 11, 2025
31b26e6
Moved workload publish check into its own script file.
MiYanni Jan 11, 2025
86e2076
Cleanup after knowing the system accesstoken is required.
MiYanni Jan 11, 2025
0799e1f
More cleanup. Fixed wrong powershell version and _BuildConfig.
MiYanni Jan 11, 2025
ad2789c
More cleanup of variable and parameter names.
MiYanni Jan 11, 2025
a56dda2
Remove NerdbankGitVersioningTasksPath workaround. Update Microsoft.Vi…
MiYanni Jan 15, 2025
3b3e492
Added usable public.yml pipeline (for PRs).
MiYanni Jan 15, 2025
416509c
Merge branch 'main' into feature/workload-publish-main
MiYanni Jan 17, 2025
ccbb539
My merge tool had an issue with the 🟣 emoji.
MiYanni Jan 17, 2025
b521be2
Move the build into a template so that workloadDropTypes isn't exposed.
MiYanni Jan 17, 2025
e4429d5
Changed vsTopicBranchId to vsTopicBranch. This allows setting the ent…
MiYanni Jan 17, 2025
e80b8dc
Trying this connection for downloading the workloads.
MiYanni Jan 17, 2025
1db531b
Back to the other subscription.
MiYanni Jan 17, 2025
0fc7204
Updated based on PR creation review.
MiYanni Jan 18, 2025
6a4cd67
Removed unused testing plugin.ps1 replacements. Using the new skipUpl…
MiYanni Jan 27, 2025
3932dcc
Trying string 'True' for the moment on skipUploadIfExists.
MiYanni Jan 28, 2025
704b647
Debugging skipUploadIfExists issues.
MiYanni Jan 28, 2025
6f880bb
Added more debugging output.
MiYanni Jan 28, 2025
3387e00
Update filtering to not use ForEach. This should let return exit the …
MiYanni Jan 28, 2025
d58d5ff
Missed commenting out a curly brace.
MiYanni Jan 28, 2025
aba7d75
See if the new MicroBuild task works now.
MiYanni Jan 29, 2025
a00e952
Removed debugging commented code and logic. Enabled version injection…
MiYanni Jan 29, 2025
573de13
Merge branch 'main' into feature/workload-publish-main2
MiYanni Jan 29, 2025
64a48c0
Update src/Microsoft.NET.Workloads.Vsman/Microsoft.NET.Workloads.Vsma…
MiYanni Feb 4, 2025
a4b87ac
Addressing a bunch of PR comments. Testing if xcopy is needed. Change…
MiYanni Feb 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<Copyright>$(CopyrightNetFoundation)</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<!-- <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DebugType>embedded</DebugType>
<DebugSymbols>true</DebugSymbols> -->
<LangVersion>Latest</LangVersion>
<NoSwixBuildPlugin>true</NoSwixBuildPlugin>
<!-- See: https://dev.azure.com/devdiv/DevDiv/_wiki/wikis/DevDiv.wiki/29608/How-to-Build-a-vsman-file?anchor=creating-your-.vsman-file -->
<GetBuildVersionTargetDefined>true</GetBuildVersionTargetDefined>
</PropertyGroup>

</Project>
1 change: 1 addition & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
<!-- Need to update the workloads version after the arcade targets have run -->
<WorkloadsVersion Condition="'$(VersionSuffix)' != ''">$(WorkloadsVersion)-$(VersionSuffix)</WorkloadsVersion>
</PropertyGroup>

</Project>
19 changes: 18 additions & 1 deletion README.md
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)
- 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.
- **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.
2 changes: 1 addition & 1 deletion build.cmd
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 %*"
exit /b %ErrorLevel%
5 changes: 0 additions & 5 deletions eng/Publishing.props
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't do anything. SdkAssetsToPublish is not an item group in this repo/Arcade.

</Project>
5 changes: 0 additions & 5 deletions eng/Signing.props
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The 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>
<ItemsToSignPostBuild Remove="*.wixpack.zip" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</PropertyGroup>
<PropertyGroup>
<WixPackageVersion>3.14.0-8606.20240208.1</WixPackageVersion>
<SwixPackageVersion>1.1.87-gba258badda</SwixPackageVersion>
<SwixPackageVersion>1.1.392</SwixPackageVersion>
</PropertyGroup>
<PropertyGroup Label="EmscriptenWorkloads">
<!-- Workloads from dotnet/emsdk -->
Expand Down
91 changes: 91 additions & 0 deletions eng/create-workload-drops.ps1
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)

# 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"
# 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"
}

# Clean up intermediate build files in the workload drop folders.
$null = Get-ChildItem -Path $workloadDropPath -Include *.json, *.vsmand, files.txt -Recurse | Remove-Item

# 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"
}
88 changes: 88 additions & 0 deletions eng/download-workloads.ps1
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)

### 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
Loading