Skip to content

Update Find-Dotnet to find dotnet with compat SDK #5341

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

Conversation

rkeithhill
Copy link
Collaborator

@rkeithhill rkeithhill commented Nov 4, 2017

Fix #5260 - with this fix, folks shouldn't run afoul of the SDK version mismatch check.

Note: the branch name turns out to be a little misleading. Read further.

The approach is to see if the dotnet in the current PATH has a compatible SDK. Folks will have a globally installed dotnet if they've installed VS or have installed the .NET Core SDK themselves. The global dotnet may not have access to the SDK required by PSCore. That is, the global dotnet cannot see user local dotnet SDK installs. So if the global dotnet doesn't have the right SDK, we prepend the path to the user's local dotnet dir.

Also, update $dotnetCLIRequiredVersion to read its value from global.json so there is one less source of the truth (for the SDK version).

Fix PowerShell#5260 - with this fix folks shouldn't hit the version mismatch check.

The approach is to see if the dotnet in the current PATH has a compatible SDK.  Folks will have a globall installed dotnet if they've installed VS, VSCode C# ext or have  installed the .NET Core SDK.  This verion may not have the SDK required by PSCore.  And the global cannot see user local dotnet SDK installs.  So if the global dotnet doesn't have the right SDK, we prepend the path to the user's local dotnet dir.

Also, updateed $dotnetCLIRequiredVersion to read its value from global.json so there is one less source of the truth (for the SDK version).
@@ -3,7 +3,7 @@
$script:TestModulePathSeparator = [System.IO.Path]::PathSeparator

$dotnetCLIChannel = "release"
$dotnetCLIRequiredVersion = "2.0.2"
$dotnetCLIRequiredVersion = $(Get-Content $PSScriptRoot/global.json | ConvertFrom-Json).Sdk.Version
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we stop if global.json does not contain Sdk version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It would be highly unusual for global.json to be missing that field since that's about its only purpose.

@bergmeister
Copy link
Contributor

That's great. I found the old behaviour really annoying because every update of VS Preview always installed the .Net Core SDK (sometimes it even ended up with multiple installations of the same version!)

@adityapatwardhan adityapatwardhan merged commit 34600c4 into PowerShell:master Nov 10, 2017
@rkeithhill rkeithhill deleted the rkeithhill/always-use-downloaded-dotnet-sdk branch May 29, 2019 15:20
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.

.NET Core tools version check in build.psm1 blocks the build
6 participants