Closed Sathyaish closed 4 years ago
MSBuild is currently using DotNet Core SDK 2.1.401 which was not found on your machine. Currently used version is defined in .\build\Versions.props
.
When SDK is not found, the script attepmts to download and install it automatically, however in your case the download failed. Any idea why? On my machine the script downloads SDK correctly. The link from log is correct.
Please, install DotNet Core SDK 2.1.401 and rebuild the project.
Does this happen consistently? Can you open https://dotnetcli.azureedge.net/dot net/Sdk/2.1.401/dotnet-dev-win-x64.2.1.401.zip
in a browser? I don't think we've seen this step fail very often.
Thank you, @michal-pawlowski and @rainersigwald .
I was able to download the zip file from https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.401/dotnet-sdk-2.1.401-win-x64.zip
and unzip it, but now I have a new problem. Its contents look like it is actually a non-installable X-copyable (like old win32 files) version of .NET Core. How do I merge it with the other versions of .NET Core that exist on my machine?
My problem is detailed on this Stack Overflow question.
Currently used version is defined in .\build\Versions.props.
Thanks. Missed that. Edited Version.props
to need the latest version 2.1.500
and trying it. Will report.
Ok, this is strange. I edited Version.props
to make it need version 2.1.500. And I do have that version. But running build.cmd
attempts to now try and download version 2.1.500
of .NET Core.
It's not yet done so I'll know in some time what's going on, but in the meantime, I looked up build.ps1
(called by build.cmd
on Windows), and here's probably the culprit code.
[CmdletBinding(PositionalBinding=$false)]
Param(
...
# This is set to an empty string
[string] $DotNetCoreSdkDir = "",
)
function Build {
if (![string]::IsNullOrEmpty($DotNetCoreSdkDir) -and (Test-Path -Path $DotNetCoreSdkDir)) {
$env:DOTNET_INSTALL_DIR = $DotNetCoreSdkDir
}
else {
# The flow-of-control probably enters here because
# the variable $(DotNetCoreSdkDir) is set to an empty
# string in the parameter declaration section of this
# script
InstallDotNetCli
}
$env:DOTNET_HOST_PATH = Join-Path $env:DOTNET_INSTALL_DIR "dotnet.exe"
...
}
I believe this is by design. We write our build scripts to be completely independent. They will download all the pieces that the build needs to succeed and also binplace them within the repo itself, so that afterwards, something like a git clean
can restore the machine to a clean state as far as the repo is concerned.
Do you know why the install script that build.cmd attempts to run is failing to download the SDK that it needs to build msbuild with? I just attempted straight up running build.cmd and everything worked for me.
@livarcocc Thanks. I did set out to find out the reason and then got busy doing something else. I have it on my list and will get to it when I can (coming few days) and post here.
Aaargh! It took me all of today to figure out what was wrong.
After a lot of putting in Set-Verbose
or Write-Host "" -ForegroundColor Red
statements, and stepping through the $(ProjectRoot)\artifacts\.dotnet\$(DotNetCliVersion)\dotnet-install.ps1
, scanning through my event logs, reading a ton of documentation, and after many a wild goose chases down the wrong alley, many false leads, here is what was wrong:
Fiddler is set up as a system wide proxy for me at port 8888
on the localhost
. This was my default system proxy and I wasn't running the Fiddler process, so the attempts to download the first downloadable file, namely, https://dotnetcli.azureedge.net/dotnet/Sdk/2.1 .401/dotnet-sdk-2.1.401-win-x64.zip
failed.
I tried removing the system-wide proxy 127.0.0.1:8888 from the Win Inet options / Control Panel / Internet Options but I don't know why, Fiddler would re-instate itself as the proxy. I changed Fiddler -> Tools -> Telerik Fiddler Options -> Connections and unchecked Act as a system proxy on start-up and Monitor all connections but that didn't help either, so I just let Fiddler run while I ran the $(ProjectRoot)\build.cmd
batch file.
However, that was only half the problem.
If the script fails to download the file https://dotnetcli.azureedge.net/dotnet/Sdk/2.1 .401/dotnet-sdk-2.1.401-win-x64.zip
, it attempts to download a legacy file from the URL https://dotnetcli.azureedge.net/dotnet/ Sdk/2.1.401/dotnet-dev-win-x64.2.1.401.zip
. It turns out this URL is invalid and hence any Web request to it yields a 404. So, this needs to be updated.
Even though I have a 2 Mbps connection, it appears that the file https://dotnetcli.azureedge.net/dotnet/Sdk/2.1 .401/dotnet-sdk-2.1.401-win-x64.zip
would take only slightly more than 10 minutes to download on my machine. However, the dotnet-install.ps1
script file had a time-out set to 10 minutes for every download. This is declared in the script block that's passed to the call to the Invoke-With-Retry
method from within the GetHTTPResponse
method.
$HttpClient.Timeout = New-TimeSpan -Minutes 10
I changed it to 30 minutes and it downloaded the file.
Therefore, I advise that this limit be increased keeping in mind people like me. My connection is still far better than some of the connections in rural and sub-urban regions in South East Asia, Middle East and Africa.
I understand this is within the purview of the .NET Core CLI team and so I have posted an issue about this on their repo.
This is about the 20th time or so I am running the build process today. It appears to be going well till now except there's another timeout of 10000ms someplace, this time in one of the .csproj
files and I can't afford to hunt it down anymore. It was trying to download nuget or something. I'll have to check the logs once this build process runs fully. But I suggest that all time-outs be increased to 30 minutes just to be safe.
False chase:
I had many a false chases in tracking this but one popular one was that the Add-Type
commandlet was producing an Information entry in the event logs, so I thought something must be wrong there. Spent about 2 hours, retrying it, reading its documentation and putting in Set-Verbose
around the code. I noticed that it read something like (from the Load-Assembly
function in dotnet-install.ps1
):
Add-Type -Assembly Assembly | Out-Null
I was certain this was failing because there is no switch named -Assembly
for this commandlet. There was, however, an -AssemblyName
switch. I suspected that since the commandlet usage above was trying to download all types from the System.Net.Http
assembly, it was failing and hence all download calls (Invoke-WebRequest / HttpClient.GetAsync
) could be failing because of this.
Then, after many hours of debugging, I remembered that Powershell allows you to type partial switch names so long as what you've typed can uniquely identify the switch. So, this was a false lead.
Finally, a request:
I am looking for work. If you know someone hiring remotely, please do let me know.
I am a programmer working in .NET. I've been programming since 1997.
My family situation presently only allows me to work from home remotely. I live in Noida, India.
Hi all,
I have exactly the same issue as @Sathyaish! Seven attempts and counting without any success. I have no proxies. My Internet connection is quite good and stable. I'm getting the same errors after the SDK download attempt.
What I am trying to do
I just want to get the source code for MS Build on my machine so I can play with it and step through the code.
What I have
I had .NET Core version 2.1.500 on my machine. I also have Visual Studio 2017 Community.
Steps to reproduce
As per the instructions here:
build.cmd
.Expected behavior
I expected the
build.cmd
file to run successfully.Actual behavior
I got the following error:
Environment data
OS info: Windows 7 Home Premium 64-bit