You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
.NET Core tools version check in build.psm1 blocks the build #5260
Condition in build.psm1 seems to be looking for exact match with "2.0.0", while the tools are of "2.0.2". This blocks the build.
$dotnetCLIRequiredVersion = "2.0.0"
...
# Verify if the dotnet in-use is the required version
$dotnetCLIInstalledVersion = (dotnet --version)
If ($dotnetCLIInstalledVersion -ne $dotnetCLIRequiredVersion) {
Write-Warning @"
The currently installed .NET Command Line Tools is not the required version.
...
Do you have a global.json file in the root of the repo? It's contents should specify that PowerShell currently uses the 2.0.0 version of the SDK. The gist is that the presence of this file should cause dotnet --version to return 2.0.0if that command is run within the repo dir structure. From that code snippet, I can't tell which dir the command is run from. I suspect the dir isn't being set to the repo path which would cause this problem.
Try this, cd into your local PowerShell repo and run dotnet --version. What version do you get?
Hmm, that is not what I see but I have both 2.0.0 and 2.0.2 installed. Which versions do you have in your C:\Program Files\dotnet\sdk and C:\Users\anmenaga\AppData\Local\Microsoft\dotnet\sdk folders?
Hmm, I wonder why dotnet is not seeing the sdk under you AppData dir. As an experiment, would you be willing to install the .NET SDK from here, restart PowerShell and then re-run dotnet --version from the PowerShell repo folder. Does that still report 2.0.2?
There's definitely an argument to be made to simply let global.json inform of dotnet of the desired version of the SDK and let dotnet determine compatibility.
That said, it seems like there is a bug in dotnet because on my system with both 2.0.0 and 2.0.2, dotnet --version reports 2.0.0 in the PowerShell repo. Not sure why the OP isn't seeing the same thing given they also have both the 2.0.2 and 2.0.0 SDK installed.
'dotnet' does not consider versions that were installed to the user's AppData folder; this is by design.
"That will install .NET Core 2.0.0 into the user's AppData folder" - consider changing this installation location.
Question for PowerShellTeam, why does the build system install into the user's AppData folder instead of the normal program files location? Because of the need to elevate? As it stands now, the global.json file apparently will not help unless the user has installed .NET Core SDK ahead of time.
An interesting observation...
On my machine "Program Files\dotnet" location (with version 2.0.2) was in %PATH% system-wide env var. Looks like it was added there when I recently installed Visual Studio 2017 (I've confirmed on a clean machine that VS2017 adds to the %PATH% system-wide env var).
When I changed %PATH% env var to have AppData|2.0.0 location instead - things started working again.
We use the dotnet-install.ps1 script from 'dotnet/cli' repo to install dotnet sdk, and it installs dontet to AppData folder by default.
The global.json file did resolve the same build issue in our AppVeyor CI about 2 weeks ago. It seemed there was an update to the "Server 2016+VS2107" image we are using in AppVeyor. The new image has dotnet installed in Program Files, and caused Start-PSBuild to stop working. Then we merged the PR #5118 and the CI started to work again. I guess that was because the dotnet installed at Program Files has both 2.0.2 and 2.0.0 installed (need to verify it myself).
Just verified on an AppVeyor builder. The dotnet SDK installed at C:\Program Files\dotnet has the following versions installed. That's why global.json fixed the CI runs.
Set the environment variable MULTI_LEVEL_LOOKUP to false to disable it.
The install script is used to download a ZIP and it puts the contents of the ZIP in the path for your current shell session. We don't make any statements regarding the dotnet host being able to find the SDK in the default location that the install script installs the SDK.
Also note that if you use the install script, the expectation is that you will run dotnet.exe from where the script installed the SDK, and the host will find the SDK that is sitting right next to it.
It appears to me that this is likely to work correctly the first time the user bootstraps the build env as the install-dotnet script adds the download path (user's appdata dir) to the PowerShell process's path. After that session is closed, the user is at the mercy of what they have officially installed AFAICT because the build script is executing dotnet as in dotnet --version, dotnet restore, etc. There is no attempt to use the version of dotnet that the bootstrapper installed. This seems a bit perilous.
One option is to use the install-dotnet script to install into $env:ProgramFiles\dotnet (on Windows) but would require elevation. Another option is to configure $dotnet as a path to the executable where that path is under the user's app data folder. Finally, you could try setting $env:MULTI_LEVEL_LOOKUP="false" but I'm still a little fuzzy as to what that actually does.
I've been looking at how the PowerShellEditorServices does this. It installs into a .dotnet folder at the root of the repo. You'd need to gitignore that but that is another option to consider.
OK did a bit more investigating into this. I removed the 2.0.2 SDK that was in my C:\Program Files\dotnet\sdk dir and also removed the one from my app data dir. Then I bootstrapped and tried to build w/no joy:
14:109ms> ipmo .\build.psm1
15:88ms> Start-PSBootstrap
Installing PowerShell build dependencies
dotnet not present. Installing dotnet.
dotnet-install: Downloading link: https://dotnetcli.azureedge.net/dotnet/Sdk/2.0.2/dotnet-sdk-2.0.2-win-x64.zip
dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Sdk/2.0.2/dotnet-sdk-2.0.2-win-x64.zip
dotnet-install: Adding to current process PATH: "C:\Users\Keith\AppData\Local\Microsoft\dotnet\". Note: This change will not be visible if PowerShell was run as a child process.
dotnet-install: Installation finished
17:367ms> gcm dotnet
CommandType Name Version Source
----------- ---- ------- ------
Application dotnet.exe 2.0.255... C:\Program Files\dotnet\dotnet.exe
18:133ms> Start-PSBuild
WARNING: The currently installed .NET Command Line Tools is not the required version.
Installed version: 2.0.0
Required version: 2.0.2
Fix steps:
1. Remove the installed version from:
- on windows '$env:LOCALAPPDATA\Microsoft\dotnet'
- on macOS and linux '$env:HOME/.dotnet'
2. Run Start-PSBootstrap or Install-Dotnet
3. Start-PSBuild -Clean
The problem is that the precheck method is looking for anydotnet in the path. In this case, it finds the dotnet in C:\Program Files\dotnet which is not able to see the SDK that was just downloaded.
This can be fixed by having Find-Dotnet first check to see if dotnet is in the current path and if so, does it have the required SDK version. If it does then we use it. Mostly likely this dotnet is the global dotnet in which case we avoided installing dotnet when it doesn't need to be installed.
More importantly though, we don't settle on a version of dotnet (global) that doesn't have the required SDK. In the case the globally installed dotnet doesn't have the required SDK, we prepend the user's local path for dotnet. If we can't find dotnet or the required SDK in the user's local dotnet dir, this triggers a user local installation of dotnet.
Activity
rkeithhill commentedon Oct 27, 2017
Do you have a
global.jsonfile in the root of the repo? It's contents should specify that PowerShell currently uses the 2.0.0 version of the SDK. The gist is that the presence of this file should causedotnet --versionto return2.0.0if that command is run within the repo dir structure. From that code snippet, I can't tell which dir the command is run from. I suspect the dir isn't being set to the repo path which would cause this problem.Try this, cd into your local PowerShell repo and run
dotnet --version. What version do you get?anmenaga commentedon Oct 27, 2017
All commands are run from PowerShell repo root
C:\github\PowerShellrkeithhill commentedon Oct 27, 2017
Hmm, that is not what I see but I have both 2.0.0 and 2.0.2 installed. Which versions do you have in your
C:\Program Files\dotnet\sdkandC:\Users\anmenaga\AppData\Local\Microsoft\dotnet\sdkfolders?anmenaga commentedon Oct 27, 2017
rkeithhill commentedon Oct 27, 2017
Anything in the
C:\Users\anmenaga\AppData\Local\Microsoft\dotnet\sdkfolder?anmenaga commentedon Oct 27, 2017
rkeithhill commentedon Oct 27, 2017
Hmm, I wonder why
dotnetis not seeing the sdk under you AppData dir. As an experiment, would you be willing to install the .NET SDK from here, restart PowerShell and then re-rundotnet --versionfrom the PowerShell repo folder. Does that still report 2.0.2?IISResetMe commentedon Oct 28, 2017
Can't we optimize the version check in
build.psm1to do ordinal version comparison after validating the major version of the dotnet CLI?PowerShell seems to compile just fine with version
2.0.2rkeithhill commentedon Oct 28, 2017
There's definitely an argument to be made to simply let global.json inform of
dotnetof the desired version of the SDK and letdotnetdetermine compatibility.That said, it seems like there is a bug in
dotnetbecause on my system with both 2.0.0 and 2.0.2,dotnet --versionreports2.0.0in the PowerShell repo. Not sure why the OP isn't seeing the same thing given they also have both the 2.0.2 and 2.0.0 SDK installed.iSazonov commentedon Oct 29, 2017
We decided to use a fixed version after a number of compatibility problems.
We now expect 2.0.3 version with important patches.
iSazonov commentedon Oct 29, 2017
Maybe related https://github.com/dotnet/cli/issues/6836
rkeithhill commentedon Oct 30, 2017
It appears that perhaps the PowerShell build is installing the .NET Core SDK into a place that isn't ideal. https://github.com/dotnet/cli/issues/7928#issuecomment-340522972
Andrew (@anmenaga) This answers the question as to why you're seeing this error. Installing the .NET Core 2.0 SDK from https://www.microsoft.com/net/download/core will get you around this issue.
Question for PowerShellTeam, why does the build system install into the user's AppData folder instead of the normal program files location? Because of the need to elevate? As it stands now, the global.json file apparently will not help unless the user has installed .NET Core SDK ahead of time.
anmenaga commentedon Nov 1, 2017
Thanks Keith Hill (@rkeithhill)
An interesting observation...
On my machine "Program Files\dotnet" location (with version 2.0.2) was in %PATH% system-wide env var. Looks like it was added there when I recently installed Visual Studio 2017 (I've confirmed on a clean machine that VS2017 adds to the %PATH% system-wide env var).
When I changed %PATH% env var to have AppData|2.0.0 location instead - things started working again.
iSazonov commentedon Nov 1, 2017
Should we document this and/or add a check in Start-PSBootStrap?
daxian-dbw commentedon Nov 2, 2017
We use the
dotnet-install.ps1script from 'dotnet/cli' repo to install dotnet sdk, and it installs dontet to AppData folder by default.The
global.jsonfile did resolve the same build issue in our AppVeyor CI about 2 weeks ago. It seemed there was an update to the "Server 2016+VS2107" image we are using in AppVeyor. The new image has dotnet installed inProgram Files, and causedStart-PSBuildto stop working. Then we merged the PR #5118 and the CI started to work again. I guess that was because the dotnet installed atProgram Fileshas both 2.0.2 and 2.0.0 installed (need to verify it myself).daxian-dbw commentedon Nov 2, 2017
Just verified on an AppVeyor builder. The
dotnetSDK installed atC:\Program Files\dotnethas the following versions installed. That's whyglobal.jsonfixed the CI runs.rkeithhill commentedon Nov 4, 2017
Got this info from the dotnet/cli folks:
It appears to me that this is likely to work correctly the first time the user bootstraps the build env as the install-dotnet script adds the download path (user's appdata dir) to the PowerShell process's path. After that session is closed, the user is at the mercy of what they have officially installed AFAICT because the build script is executing
dotnetas indotnet --version,dotnet restore, etc. There is no attempt to use the version of dotnet that the bootstrapper installed. This seems a bit perilous.One option is to use the install-dotnet script to install into
$env:ProgramFiles\dotnet(on Windows) but would require elevation. Another option is to configure$dotnetas a path to the executable where that path is under the user's app data folder. Finally, you could try setting$env:MULTI_LEVEL_LOOKUP="false"but I'm still a little fuzzy as to what that actually does.rkeithhill commentedon Nov 4, 2017
I've been looking at how the PowerShellEditorServices does this. It installs into a
.dotnetfolder at the root of the repo. You'd need to gitignore that but that is another option to consider.rkeithhill commentedon Nov 4, 2017
OK did a bit more investigating into this. I removed the 2.0.2 SDK that was in my
C:\Program Files\dotnet\sdkdir and also removed the one from my app data dir. Then I bootstrapped and tried to build w/no joy:The problem is that the
precheckmethod is looking for anydotnetin the path. In this case, it finds thedotnetinC:\Program Files\dotnetwhich is not able to see the SDK that was just downloaded.This can be fixed by having
Find-Dotnetfirst check to see if dotnet is in the current path and if so, does it have the required SDK version. If it does then we use it. Mostly likely this dotnet is the global dotnet in which case we avoided installing dotnet when it doesn't need to be installed.More importantly though, we don't settle on a version of dotnet (global) that doesn't have the required SDK. In the case the globally installed dotnet doesn't have the required SDK, we prepend the user's local path for dotnet. If we can't find dotnet or the required SDK in the user's local dotnet dir, this triggers a user local installation of dotnet.
PR coming on this.
Update Find-Dotnet to find dotnet with compat SDK
Update Find-Dotnet to find dotnet with compat SDK (#5341)
Update Find-Dotnet to find dotnet with compat SDK (PowerShell#5341)