Aspnetcore: cannot build using restore.cmd

Created on 6 Aug 2019  ·  10Comments  ·  Source: dotnet/aspnetcore

If you believe you have an issue that affects the security of the platform please do NOT create an issue and instead email your issue details to [email protected]. Your report may be eligible for our bug bounty but ONLY if it is reported through email.

Describe the bug

tried to build asp.net core and followed all steps - got following error on restore.cmd

PS C:\dotnetcore\AspNetCore> .\restore.cmd
Detected JDK in C:\dotnetcore\AspNetCore.tools\jdk\win-x64\ (via local repo convention)
C:\Users\jlee.nuget\packages\microsoft.dotnet.arcade.sdk\1.0.0-beta.19369.2\tools\Tools.proj : error : Unable to locate the .NET Core SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version.
C:\Users\jlee.nuget\packages\microsoft.dotnet.arcade.sdk\1.0.0-beta.19369.2\tools\Tools.proj : error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found.
Build failed.

To Reproduce

Steps to reproduce the behavior:

  1. Using this version of ASP.NET Core '...'
  2. Run this code '....'
  3. With these arguments '....'
  4. See error

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.
Include the output of dotnet --info

area-infrastructure

Most helpful comment

If you have Visual Studio installed, @pursca @SIkebe @sfmskywalker have you enabled preview SDKs in it? Please see the following for more information:

All 10 comments

/cc @aspnet/build

Same here...

C:\GitHub\AspNetCore>restore.cmd
Detected JDK in C:\Program Files\AdoptOpenJDK\jdk-8.0.222.10-hotspot C:\Program Files\AdoptOpenJDK\jdk-11.0.3.7-hotspot (via PATH)
C:\Users\Shoda\.nuget\packages\microsoft.dotnet.arcade.sdk\1.0.0-beta.19369.2\tools\Tools.proj : error : .NET Core SDK が見つかりません。インストールされていること、および (存在する場合には) そのインストール済みバージョンが global.json  で指定されたバージョンと一致していることを確認してください。
C:\Users\Shoda\.nuget\packages\microsoft.dotnet.arcade.sdk\1.0.0-beta.19369.2\tools\Tools.proj : error MSB4236: 指定された SDK 'Microsoft.NET.Sdk' は見つかりませんでした。
Build failed.

C:\GitHub\AspNetCore>dotnet --info
.NET Core SDK (global.json を反映):
 Version:   3.0.100-preview7-012821
 Commit:    6348f1068a

ランタイム環境:
 OS Name:     Windows
 OS Version:  10.0.18362
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100-preview7-012821\

Host (useful for support):
  Version: 3.0.0-preview7-27912-14
  Commit:  4da6ee6450

.NET Core SDKs installed:
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.505 [C:\Program Files\dotnet\sdk]
  2.1.507 [C:\Program Files\dotnet\sdk]
  2.1.602 [C:\Program Files\dotnet\sdk]
  2.1.603 [C:\Program Files\dotnet\sdk]
  2.1.700-preview-009597 [C:\Program Files\dotnet\sdk]
  2.1.700-preview-009601 [C:\Program Files\dotnet\sdk]
  2.1.700-preview-009618 [C:\Program Files\dotnet\sdk]
  2.1.700 [C:\Program Files\dotnet\sdk]
  2.1.701 [C:\Program Files\dotnet\sdk]
  2.1.801 [C:\Program Files\dotnet\sdk]
  2.2.203 [C:\Program Files\dotnet\sdk]
  3.0.100-preview7-012821 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview7.19365.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview7-27912-14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview7-27912-14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

C:\GitHub\AspNetCore>

I can't build the source either. However I'm getting the following:

A compatible installed .NET Core SDK for global.json version [5.0.100-alpha1-013788] from [C:\Projects\sfmskywalker\AspNetCore\global.json] was not found

Notice that global.json is specifying SDK version 5.0.100-alpha1-013788, which I do not have installed on my machine.

Should I be building a branch other than master? Or should I be able to install SDK version 5? I tried to find it, but no luck so far.

Hang on, I only now notice the following lines:

dotnet-install: Downloading link: https://dotnetcli.azureedge.net/dotnet/Sdk/5.0.100-alpha1-013788/dotnet-sdk-5.0.100-alpha1-013788-win-x64.zip
dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Sdk/5.0.100-alpha1-013788/dotnet-sdk-5.0.100-alpha1-013788-win-x64.zip

Clearly it's downloading the latest SDK the build is failing to find.
I'll dig some more.

If you have Visual Studio installed, @pursca @SIkebe @sfmskywalker have you enabled preview SDKs in it? Please see the following for more information:

That must have been it. Here's what I did to make it work on my machine:

  1. Uninstall all Visual Studio versions (2017, 2019 Community & 2019 Enterprise)
  2. Re-install 2019 Enterprise using eng/scripts/InstallVisualStudio.ps1 as described in Build ASP.NET Core from Source
  3. Open Visual Studio 2019 and enable preview SDKs.

Now the build.cmd is working as advertised :)

Although build.cmd works, there seems to be another issue preventing e.g. MVC.sln to be built. Here's what I am seeing:

Path (AspNetCore) PS C:\Projects\sfmskywalker\AspNetCore\src\mvc>

.\build

C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(4552,5): error MSB3027: Could not copy "C:\Projects\sfmskywalker\AspNetCore\src\Mvc\Mvc.Api.Analyzers\test\TestFiles\ApiActionsDoNotRequireExplicitModelValidationCheckAnalyzerIntegrationTest\NoDiagnosticsAreReturned_ForApiActionsReturningNot400FromNonModelS
tateIsValidBlock.cs" to "bin\Debug\netcoreapp5.0\TestFiles\ApiActionsDoNotRequireExplicitModelValidationCheckAnalyzerIntegrationTest\NoDiagnosticsAreReturned_ForApiActionsReturningNot400FromNonModelStateIsValidBlock.cs". Exceeded retry count of 10. Failed.  [C:\Projects\sfmskywalker\AspNetCore\src\Mvc\Mvc.Api.Analyzers\test\Mvc.Api.Analyzers.Test.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(4552,5): error MSB3021: Unable to copy file "C:\Projects\sfmskywalker\AspNetCore\src\Mvc\Mvc.Api.Analyzers\test\TestFiles\ApiActionsDoNotRequireExplicitModelValidationCheckAnalyzerIntegrationTest\NoDiagnosticsAreReturned_ForApiActionsReturningNot400FromNonM
odelStateIsValidBlock.cs" to "bin\Debug\netcoreapp5.0\TestFiles\ApiActionsDoNotRequireExplicitModelValidationCheckAnalyzerIntegrationTest\NoDiagnosticsAreReturned_ForApiActionsReturningNot400FromNonModelStateIsValidBlock.cs". Could not find a part of the path 'bin\Debug\netcoreapp5.0\TestFiles\ApiActionsDoNotRequireExplicitModelValidationCheckAnalyzerIntegrationTest\NoDiagnosti
csAreReturned_ForApiActionsReturningNot400FromNonModelStateIsValidBlock.cs'. [C:\Projects\sfmskywalker\AspNetCore\src\Mvc\Mvc.Api.Analyzers\test\Mvc.Api.Analyzers.Test.csproj]

For some reason, the file NoDiagnosticsAreReturned_ForApiActionsReturningNot400FromNonM odelStateIsValidBlock.cs cannot be copied. Could it have something to do with the path length? 🤔

Could it have something to do with the path length?

Seems likely. For example I use 'C:\dd\dnx\AspNetCore\' to avoid path length issues. And, Mvc.Api.Analyzers.Test.csproj has relatively long paths.

Another workaround would be .\build.cmd -ForceCoreMsbuild because dotnet msbuild has fewer path length issues than msbuild. This might not work if you haven't built native dependencies (I didn't try building from scratch) but should be fine otherwise.

Setting COREHOST_TRACE to 1, gave me:

Building of C# project is enabled and has dependencies on NodeJS projects. Building of NodeJS projects is enabled since node is detected in C:\Program Files.
Detected JDK in C:\Program Files\Java\jdk-13 (via JAVA_HOME)
Tracing enabled @ Wed Oct  2 04:35:46 2019 GMT
--- Invoked hostfxr_resolve_sdk2 [commit hash: 7d57652f33493fa022125b7f63aad0d70c52d810]
Probing path [C:\Users\madsk\.nuget\packages\microsoft.dotnet.arcade.sdk\1.0.0-beta.19462.4\tools\global.json] for global.json
Probing path [C:\Users\madsk\.nuget\packages\microsoft.dotnet.arcade.sdk\1.0.0-beta.19462.4\global.json] for global.json
Probing path [C:\Users\madsk\.nuget\packages\microsoft.dotnet.arcade.sdk\global.json] for global.json
Probing path [C:\Users\madsk\.nuget\packages\global.json] for global.json
Probing path [C:\Users\madsk\.nuget\global.json] for global.json
Probing path [C:\Users\madsk\global.json] for global.json
Probing path [C:\Users\global.json] for global.json
Probing path [C:\global.json] for global.json
Terminating global.json search at [C:\]
Resolving SDKs with version = 'latest', rollForward = 'latestMajor', allowPrerelease = false
Searching for SDK versions in [C:\Users\madsk\workspace\AspNetCore\.dotnet\sdk]
Ignoring version [5.0.100-alpha1-013788] because it does not match the roll-forward policy
  It was not possible to find any installed .NET Core SDKs
  Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
      https://aka.ms/dotnet-download

Note allowPrerease=false for microsoft.dotnet.arcade.sdk. I had to manually enable prerelases in microsoft.dotnet.arcade.sdk\1.0.0-beta.19462.4\global.json like this:

{
    "sdk": {
        "allowPrerelease": true,
        "rollForward": "latestMajor"
    }
}

Closing because this issue is rather old and seems to cover a multitude of different problems, most of which have been resolved. Please file new issues if problems building this repo re-surface.

Was this page helpful?
0 / 5 - 0 ratings