Skip to content

Quickly check if runtime is installed#16580

Merged
akoeplinger merged 6 commits intodotnet:mainfrom
nohwnd:quick-check-dotnet-install
Mar 13, 2026
Merged

Quickly check if runtime is installed#16580
akoeplinger merged 6 commits intodotnet:mainfrom
nohwnd:quick-check-dotnet-install

Conversation

@nohwnd
Copy link
Copy Markdown
Member

@nohwnd nohwnd commented Mar 11, 2026

On every build runtimes are checked, repos are usually installing 2-4 runtimes, and spend about 10 seconds on checking if they are installed on every invocation of build.cmd.

Check if the runtime is installed directly in the msbuild task before offloading to the install script. This saves opening dotnet-install.cmd, dotnet-install.ps1, initializing powershell, dot-sourcing tools.ps1, and running the check. Overall 1.5 seconds per runtime check.

Code is copied from tools.sh and tools.ps1 and translated to C#.

Before:

nonoptimize--install-dotnet

After:

optimize-install-dotnet

Stats based on runtimes in dotnet repos, assuming 1.5 seconds per check (as for my local measurement).

Repo Installs Check Time
dotnet/arcade 0 0s
dotnet/arcade-services 2 3s
dotnet/arcade-validation 1 1.5s
dotnet/aspire 8 12s
dotnet/aspnetcore 2 3s
dotnet/blazor 1 1.5s
dotnet/cli-lab 1 1.5s
dotnet/command-line-api 1 1.5s
dotnet/corefxlab 2 3s
dotnet/diagnostics 2 3s
dotnet/dnceng 2 3s
dotnet/dnceng-shared 2 3s
dotnet/docker-tools 2 3s
dotnet/dotnet-monitor 12 18s
dotnet/efcore 1 1.5s
dotnet/extensions 6 9s
dotnet/extensions-samples 4 6s
dotnet/iot 2 3s
dotnet/machinelearning 4 6s
dotnet/maintenance-packages 1 1.5s
dotnet/msbuild 0 0s
dotnet/razor 3 4.5s
dotnet/roslyn-sdk 1 1.5s
dotnet/roslyn-tools 1 1.5s
dotnet/sdk 2 3s
dotnet/sign 1 1.5s
dotnet/systemweb-adapters 6 9s
dotnet/try-convert 3 4.5s
dotnet/tye 2 3s
dotnet/wcf 2 3s
dotnet/windowsdesktop 1 1.5s
dotnet/winforms 2 3s
dotnet/wpf 2 3s
dotnet/yarp 4 6s
microsoft/testfx 7 10.5s
microsoft/vstest 16 24s

Executed PR tests, and manually patched local installation of arcade to make the gifs and test.

Fix #16580

@nohwnd nohwnd marked this pull request as ready for review March 11, 2026 10:55
Evangelink
Evangelink previously approved these changes Mar 11, 2026
<InstallDotNetCore
VersionsPropsPath="$(RepositoryEngineeringDir)Versions.props"
GlobalJsonPath="$(RepoRoot)global.json"
DotnetPath ="$(ReporRoot).dotnet"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
DotnetPath ="$(ReporRoot).dotnet"
DotnetPath ="$(RepoRoot).dotnet"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not positive this is correct. Are you sure this is always the dotnet path?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

https://github.com/dotnet/arcade/blob/main/eng/common/tools.ps1#L185C5-L185C16 it is taken from here, when we have runtimes, this is the path to use.

We only check it in the task if we have runtimes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I can move it closer to the duplicated code directly in the check if that makes it less error prone for future development.

Co-authored-by: Matt Mitchell <mmitche@microsoft.com>
@nohwnd
Copy link
Copy Markdown
Member Author

nohwnd commented Mar 13, 2026

@akoeplinger I cannot merge here. Please merge.

@akoeplinger akoeplinger merged commit 2e8c949 into dotnet:main Mar 13, 2026
9 checks passed
<InstallDotNetCore
VersionsPropsPath="$(RepositoryEngineeringDir)Versions.props"
GlobalJsonPath="$(RepoRoot)global.json"
DotNetPath ="$(RepoRoot).dotnet"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are you sure this is correct? The SDK only gets downloaded to that location if a machine wide installed one isn't available.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is runtime specific, the code in the task would delegate to dotnet-install.sh and dotnet-install.ps1, which do this:

https://github.com/dotnet/arcade/blob/main/eng/common/dotnet-install.sh#L83
https://github.com/dotnet/arcade/blob/main/eng/common/dotnet-install.ps1#L15

Followed by the logic for setting the architecture specific root. If that makes it more clear I can pass the RepoRoot to the task, and determine the path to .dotnet, .dotnet/x86 .dotnet/arm64 in the task itself, then it is easier to point to the scripts that would be called if the quick check fails.

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.

5 participants