Skip to content

Use dotnet package download for toolset initialization - #5909

Merged
ViktorHofer merged 50 commits into
mainfrom
dotnet-package-download
Apr 9, 2026
Merged

ViktorHofer merged 50 commits into
mainfrom
dotnet-package-download

Conversation

@ViktorHofer

@ViktorHofer ViktorHofer commented Apr 4, 2026 •

Copy link
Copy Markdown
Member

Includes dotnet/arcade#16681.
Validation build: https://dev.azure.com/dnceng/internal/_build/results?buildId=2947250&view=results

Summary

Replaces the MSBuild-based restore in InitializeToolset with dotnet package download, adds a reusable DotNet helper function to tools.sh/tools.ps1, and migrates the Arcade SDK package layout from tools/ to a new toolset/ folder with backward-compatible fallbacks.

Motivation

The previous toolset initialization approach used an MSBuild restore (/t:__WriteToolsetLocation) to discover and extract the Arcade SDK toolset. This was indirect—it required a special target, a temporary .txt file for path communication, and _SuppressSdkImports logic in Sdk.props/Sdk.targets to avoid importing targets during the discovery phase. Replacing it with dotnet package download simplifies the flow and removes several layers of indirection.

Changes

New DotNet helper function (tools.ps1 / tools.sh)

  • Standardized wrapper for executing dotnet commands with proper error handling, exit code propagation, and CI pipeline integration (Write-PipelineSetResult on failure).
  • Sets ARCADE_BUILD_TOOL_COMMAND environment variable for telemetry tracking.

Toolset initialization rewrite (InitializeToolset)

  • Old: Ran MSBuild /t:__WriteToolsetLocation on a restore.proj to write the toolset path to a .txt file, then read that file.
  • New: Calls dotnet package download to fetch the Arcade SDK NuGet package, then copies the toolset/ (or tools/ as fallback) content directly to the toolset directory. References Build.proj directly.
  • Removes the __WriteToolsetLocation target from Sdk.targets and the _SuppressSdkImports conditional logic from Sdk.props/Sdk.targets.

Arcade SDK package layout migration (tools/ → toolset/)

  • New folder: toolset/ at the package root now contains Build.proj, Sign.proj, Publish.proj, Tools.proj, Directory.Build.props, Directory.Build.targets, Directory.Packages.props, and all former SdkTasks/*.proj files.
  • Removed files: BuildStep.props, tools/Directory.Build.props, tools/SdkTasks/Directory.Build.props, tools/SdkTasks/Versions.props, tools/Tools.proj.
  • Added: EmptyDisableRestore.targets (extracted from Empty.targets for conditional restore suppression).
  • Centralized <UsingTask> declarations in BuildTasks.props instead of scattering them across individual target files.
  • GetSdkTaskProject() now checks $toolsetDir/$taskName.proj first (new flat layout), then falls back to $toolsetDir/SdkTasks/$taskName.proj (legacy layout).

UpdateJson.cs enhancements

  • Added ValuesToUpdate parameter for batch-updating multiple JSON properties in a single invocation (case-insensitive key matching).
  • Refactored internal navigation with TryNavigateToObject() helper replacing the recursive UpdateAttribute().

VMR build orchestration updates (repo-projects/)

  • Reordered dependency targets: DiscoverBuiltSdkOverrides now runs before UpdateGlobalJsonVersions.
  • New UpdateJson invocations to update the bootstrap Arcade SDK version and source-built SDK overrides.
  • Exports NUGET_CONFIG environment variable for misc project builds.

Publishing and source-build updates

  • eng/PublishSourceBuild.props: Changed target dependencies from AfterTargets="Publish" to AfterTargets="Execute".
  • eng/Publishing.props: Added RestoreSources override for source-only builds and a restore-skip condition on DiscoverArtifacts.
  • eng/source-build-toolset-init.sh: Updated path lookup to prefer toolset/ with tools/ fallback.
  • sdk-task.ps1/sdk-task.sh: Updated help text to reference toolset directory instead of SdkTasks directory.

Port of dotnet/arcade#16681. Replaces the
MSBuild-based restore in InitializeToolset with 'dotnet package download',
adds a reusable DotNet helper function to tools.sh/tools.ps1, and moves
SdkTasks to a new 'toolset' folder at the package root with backward
compatible fallbacks for the old layout.

Co-authored-by: Copilot <[email protected]>
@dotnet-policy-service
dotnet-policy-service Bot requested a review from a team April 4, 2026 07:47
@dotnet-policy-service
dotnet-policy-service Bot requested a review from a team April 4, 2026 09:57
@dotnet-policy-service
dotnet-policy-service Bot requested a review from a team April 4, 2026 10:35
@dotnet-policy-service
dotnet-policy-service Bot requested review from a team April 6, 2026 07:57
@dotnet-policy-service
dotnet-policy-service Bot requested a review from a team April 6, 2026 08:45
@dotnet-policy-service
dotnet-policy-service Bot requested a review from a team April 7, 2026 10:21
ViktorHofer and others added 6 commits April 9, 2026 00:31
Add logic to update child elements of a JSON object node based on
ITaskItem[] with Identity/Value metadata. Refactor path navigation
into a shared TryNavigateToObject method, replacing the previous
recursive approach.

Update Directory.Build.targets to use the new ValuesToUpdate parameter
for SourceBuiltSdkOverride items when updating msbuild-sdks entries
in global.json files.

Co-authored-by: Copilot <[email protected]>
@ViktorHofer
ViktorHofer marked this pull request as ready for review April 9, 2026 11:16
@ViktorHofer
ViktorHofer requested review from a team as code owners April 9, 2026 11:16
Copilot AI review requested due to automatic review settings April 9, 2026 11:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the VMR/Arcade toolset initialization flow by replacing the MSBuild-based “restore to discover toolset” approach with dotnet package download, and migrates the Arcade SDK package’s build entrypoints from tools/ to a new toolset/ layout (with compatibility fallbacks). It also modernizes several Arcade toolset projects to use SDK-style + PackageReference/CPM, and extends the VMR UpdateJson task to support batch updates.

Changes:

  • Rewrite toolset initialization to use dotnet package download + extract toolset/ (fallback tools/), with new DotNet helpers in tools.sh/tools.ps1.
  • Migrate Arcade SDK package layout from tools/ → toolset/, centralizing task declarations and converting multiple .proj files to SDK-style with package references.
  • Enhance UpdateJson MSBuild task to support ValuesToUpdate for batch updates and update repo-project orchestration to apply additional global.json updates and env vars.
Show a summary per file
File Description
src/windowsdesktop/src/windowsdesktop/src/bundle/Wix.targets Switch to namespaced Arcade DownloadFile task
src/sdk/src/Tasks/sdk-tasks/sdk-tasks.InTree.targets Normalize UsingTask declarations
src/sdk/src/Layout/redist/targets/RestoreLayout.targets Use namespaced DownloadFile task
src/sdk/src/Layout/redist/targets/GenerateMSIs.targets Use namespaced DownloadFile task
src/roslyn/src/Setup/DevDivInsertionFiles/DevDivInsertionFiles.csproj Add Arcade 11 upgrade TODOs / reorder UsingTask
src/roslyn/src/NuGet/VS.Tools.Roslyn.Package/VS.Tools.Roslyn.Package.csproj Add Arcade 11 upgrade TODO
src/roslyn/eng/targets/Imports.targets Add Arcade 11 upgrade TODO
src/roslyn/eng/targets/GeneratePkgDef.targets Add Arcade 11 upgrade TODO / whitespace cleanup
src/roslyn/eng/Publishing.props Change pr-validation/source-only artifact filtering logic
src/nuget-client/eng/dotnet-build/dotnet-build.proj Point ArcadeDir to toolset/ + Publish target rename
src/fsharp/src/Microsoft.FSharp.Compiler/Microsoft.FSharp.Compiler.fsproj Switch NuGetRepack usage to package reference + explicit task assembly
src/aspnetcore/src/Installers/Windows/WindowsHostingBundle/Product.targets Use namespaced DownloadFile task
src/aspnetcore/src/Framework/App.Runtime/src/aspnetcore-runtime.proj Use namespaced DownloadFile task
src/aspnetcore/src/Framework/App.Runtime/src/aspnetcore-runtime-composite.proj Use namespaced DownloadFile task
src/aspnetcore/eng/tools/RepoTasks/RepoTasks.tasks Remove Arcade DownloadFile UsingTask
src/arcade/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs Treat empty Wix paths as unset
src/arcade/src/Microsoft.DotNet.NuGetRepack/tasks/build/Microsoft.DotNet.NuGetRepack.Tasks.props New props with task assembly + UsingTask
src/arcade/src/Microsoft.DotNet.Build.Tasks.VisualStudio/build/Microsoft.DotNet.Build.Tasks.VisualStudio.props New props with task assembly + UsingTask
src/arcade/src/Microsoft.DotNet.Build.Tasks.Installers/build/acquisition/acquire-wix/acquire-wix.proj Use namespaced DownloadFile task
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/VisualStudio.SetupPackage.vsmanproj Minor target formatting reorder
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/VisualStudio.InsertionManifests.targets Move default GenerateSbom property group
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/VisualStudio.IbcTraining.runsettings Add runsettings template file
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/VisualStudio.BuildIbcTrainingSettings.proj Convert to SDK-style + PackageReference
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/VisualStudio.BuildIbcTrainingInputs.targets Convert to PackageReference
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/VisualStudio.AcquireOptimizationData.targets Convert to PackageReference
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/TrackPrebuiltUsage.targets Convert SourceBuild.Tasks to PackageReference
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/Tools.proj New SDK-style tool restore entrypoint
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/SigningValidation.proj Convert to CPM PackageReference pattern
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/Sign.props Use ArcadeSdkSnkDir-based key paths
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/Sign.proj Convert to SDK-style + PackageReference/PackageDownload
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/PublishToSymbolServers.proj Convert to CPM PackageReference pattern
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/PublishSignedAssets.proj Convert to CPM PackageReference pattern
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/PublishBuildAssets.proj Convert to CPM PackageReference pattern
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/PublishArtifactsInManifest.proj Convert to CPM PackageReference pattern
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/Publish.proj Convert to SDK-style + rename Publish→Execute + restore changes
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/InstallDotNetCore.targets Rely on centralized task imports
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/Directory.Packages.props New CPM versions for toolset projs
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/Directory.Build.targets Import Arcade SDK targets for toolset projs
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/Directory.Build.props Toolset-wide defaults + Arcade SDK import
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/CreateBaselineUpdatePR.proj Convert to CPM PackageReference pattern
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/BuildReleasePackages.targets Switch NuGetRepack to PackageReference
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/Build.proj Convert to SDK-style + update target wiring (Execute)
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/AfterSolutionBuild.proj Convert to SDK-style shell
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/toolset/AfterSigning.proj Convert to SDK-style shell
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/VisualStudio.VsixBuild.targets Remove explicit VisualStudio task UsingTask
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/VisualStudio.props Remove explicit VS build tasks assembly property
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/Version.targets Remove explicit UsingTask (centralized)
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/Tools.proj Delete legacy tools/Tools.proj
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/StrongName.targets Use ArcadeSdkSnkDir for key files
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/StrongName.props Introduce ArcadeSdkSnkDir property
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/SdkTasks/Versions.props Delete legacy versions props
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/SdkTasks/Directory.Build.props Delete legacy sdk-tasks Directory.Build.props
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/RuntimeIdentifierInference.BeforeNETSdkTargets.targets Remove explicit _SuppressAllTargets assignment
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/RepositoryValidation.proj Remove redundant UsingTask declarations
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/RepositoryInfo.targets Inline repository validation/license checks via Arcade tasks
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/OptimizationData.targets Remove redundant UsingTask declarations
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/GenerateResxSource.targets Remove redundant UsingTask declarations
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/GenerateChecksums.targets Remove redundant UsingTask declarations
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/ExcludeFromBuild.BeforeCommonTargets.targets Gate NoRestore.targets selection on _NoSuppressRestoreTarget
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/EmptyDisableRestore.targets New restore-suppression helper targets
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/Empty.targets Expand “no-op” targets + conditional restore suppression
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/Directory.Build.props Delete empty Directory.Build.props
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/DefaultVersions.props Adjust default version properties
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/BuildTasks.props Centralize Arcade SDK UsingTask declarations
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/BuildStep.props Delete legacy BuildStep.props
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/sdk/Sdk.targets Remove __WriteToolsetLocation + adjust import gating
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/sdk/Sdk.props Remove _SuppressSdkImports bootstrap logic
src/arcade/src/Microsoft.DotNet.Arcade.Sdk/Microsoft.DotNet.Arcade.Sdk.csproj Pack toolset/ content into NuGet package
src/arcade/eng/common/tools.sh Toolset init via dotnet package download + DotNet helper + new GetSdkTaskProject resolution
src/arcade/eng/common/tools.ps1 Toolset init via dotnet package download + DotNet helper + new GetSdkTaskProject resolution
src/arcade/eng/common/sdk-task.sh Update help text for toolset directory
src/arcade/eng/common/sdk-task.ps1 Update help text for toolset directory
repo-projects/Directory.Build.targets Reorder orchestration deps + UpdateJson batch updates for global.json
repo-projects/Directory.Build.props Export NUGET_CONFIG env var to inner builds
eng/tools/tasks/Microsoft.DotNet.UnifiedBuild.Tasks/UpdateJson.cs Add ValuesToUpdate + refactor navigation
eng/Tools.props Formatting + source-build restore source behavior adjustments
eng/source-build-toolset-init.sh Prefer toolset/ with tools/ fallback
eng/PublishSourceBuild.props Update AfterTargets Publish→Execute + restore-skip conditions
eng/Publishing.props Add SB RestoreSources override + gate artifact discovery during restore
eng/common/tools.sh Toolset init via dotnet package download + DotNet helper + warnnotaserror gating
eng/common/tools.ps1 Toolset init via dotnet package download + DotNet helper + warnnotaserror gating

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 80/81 changed files
  • Comments generated: 2

Comment thread src/roslyn/eng/Publishing.props Resolved
@ViktorHofer
ViktorHofer merged commit fffb123 into main Apr 9, 2026
7 of 11 checks passed
@ViktorHofer
ViktorHofer deleted the dotnet-package-download branch April 9, 2026 17:28
@am11

am11 commented Apr 18, 2026

Copy link
Copy Markdown
Member

Noticed a regression in downstream workflows. Fixed by #6121.

ellahathaway added a commit to ellahathaway/dotnet that referenced this pull request Apr 24, 2026
The SetFileSignInfoForSourceAsset target used BeforeTargets="Sign", but
dotnet#5909 renamed the Sign target to Execute in Arcade's
Sign.proj. This caused DoNotUnpack to never be applied to the source
tarball, resulting in SignTool unpacking and attempting to sign all files
inside it.

Fix BeforeTargets to reference Execute so the source tarball is no
longer unpacked during signing.

Fixes: dotnet/source-build#5551

Co-authored-by: Copilot <[email protected]>
@mmitche

mmitche commented Apr 27, 2026

Copy link
Copy Markdown
Member

This looks like it breaks some arcade scenarios...specifically build promotion

@ViktorHofer

Copy link
Copy Markdown
Member Author

Please share those with me on teams

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants