Quickly check if runtime is installed#16580
Conversation
| <InstallDotNetCore | ||
| VersionsPropsPath="$(RepositoryEngineeringDir)Versions.props" | ||
| GlobalJsonPath="$(RepoRoot)global.json" | ||
| DotnetPath ="$(ReporRoot).dotnet" |
There was a problem hiding this comment.
| DotnetPath ="$(ReporRoot).dotnet" | |
| DotnetPath ="$(RepoRoot).dotnet" |
There was a problem hiding this comment.
I'm not positive this is correct. Are you sure this is always the dotnet path?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>
src/Microsoft.DotNet.Arcade.Sdk/tools/InstallDotNetCore.targets
Outdated
Show resolved
Hide resolved
|
@akoeplinger I cannot merge here. Please merge. |
| <InstallDotNetCore | ||
| VersionsPropsPath="$(RepositoryEngineeringDir)Versions.props" | ||
| GlobalJsonPath="$(RepoRoot)global.json" | ||
| DotNetPath ="$(RepoRoot).dotnet" |
There was a problem hiding this comment.
Are you sure this is correct? The SDK only gets downloaded to that location if a machine wide installed one isn't available.
There was a problem hiding this comment.
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.
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:
After:
Stats based on runtimes in dotnet repos, assuming 1.5 seconds per check (as for my local measurement).
Executed PR tests, and manually patched local installation of arcade to make the gifs and test.
Fix #16580