dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.39k stars 10k forks source link

The SDK 'Microsoft.NET.Sdk.BlazorWebAssembly' specified could not be found. #29700

Closed sroy2020 closed 3 years ago

sroy2020 commented 3 years ago

Describe the bug

I can't build using a build pipeline on an on-premise DevOps Server. So I decided to create a small project and compile manually on the same server. Unfortunately, I have the same error the build pipeline is reporting. The build fails with the following error

"C:\Users\SRoy\z\qwerty\qwerty.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk.BlazorWebAssembly' specified could not be found."

To Reproduce

I created a small Blazor WASM using the command "dotnet new blazorwasm -o qwerty". Then run "dotnet build" inside the qwerty folder. The build fails with the error above.

Exceptions (if any)

The SDK 'Microsoft.NET.Sdk.BlazorWebAssembly' specified could not be found."

Further technical details

qwerty.csproj contains:

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.2" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.2" PrivateAssets="all" />
    <PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
  </ItemGroup>

</Project>

global.json in qwerty folder contains:

{
  "sdk": {
    "version": "5.0.102"
  }
}
C:\Users\SRoy\z\qwerty>dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.102
 Commit:    71365b4d42

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.102\

Host (useful for support):
  Version: 5.0.2
  Commit:  cb5f173b96

.NET SDKs installed:
  3.1.201 [C:\Program Files\dotnet\sdk]
  3.1.300 [C:\Program Files\dotnet\sdk]
  5.0.100 [C:\Program Files\dotnet\sdk]
  5.0.102 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
C:\Users\SRoy\z\qwerty>dotnet --list-sdks
3.1.201 [C:\Program Files\dotnet\sdk]
3.1.300 [C:\Program Files\dotnet\sdk]
5.0.100 [C:\Program Files\dotnet\sdk]
5.0.102 [C:\Program Files\dotnet\sdk]

folderDotnet

I really don't have any clue what could be wrong. Doing the very same on my workstation is fine.

Thanks in advance Stéphane Roy

javiercn commented 3 years ago

@sroy2020 thanks for contacting us.

That seems like an issue with the installation on your build machine. I would suggest you repair the installation or try downloading and using the 5.1.102 SDK binaries and use that directly. For that:

Then create a new blazor webassembly application and build it. If it works, it means that there's some issue in your installation, so I would suggest reinstalling the SDK

sroy2020 commented 3 years ago

Hi,

I downloaded and installed the binaries using the zip and then followed the procedure. Unfortunately, I get the same error. Below is the output captured in text and as a screenshot.

Do you have any other recommendations?

Thanks in advance Stéphane Roy

PS C:\Users\SRoy> cd x
PS C:\Users\SRoy\x> $env:DOTNET_ROOT = "C:\Tmp\dotnet-sdk-5.0.102-win-x64"
PS C:\Users\SRoy\x> $env:DOTNET_MULTILEVEL_LOOKUP = 0;
PS C:\Users\SRoy\x> $env:Path = "C:\Tmp\dotnet-sdk-5.0.102-win-x64;$env:Path";
PS C:\Users\SRoy\x> ls
PS C:\Users\SRoy\x> dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.102
 Commit:    71365b4d42

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Tmp\dotnet-sdk-5.0.102-win-x64\sdk\5.0.102\

Host (useful for support):
  Version: 5.0.2
  Commit:  cb5f173b96

.NET SDKs installed:
  5.0.102 [C:\Tmp\dotnet-sdk-5.0.102-win-x64\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 5.0.2 [C:\Tmp\dotnet-sdk-5.0.102-win-x64\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 5.0.2 [C:\Tmp\dotnet-sdk-5.0.102-win-x64\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 5.0.2 [C:\Tmp\dotnet-sdk-5.0.102-win-x64\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
PS C:\Users\SRoy\x> dotnet new blazorwasm -o qwerty
The template "Blazor WebAssembly App" was created successfully.
This template contains technologies from parties other than Microsoft, see https://aka.ms/aspnetcore/5.0-third-party-notices for details.

Processing post-creation actions...
Running 'dotnet restore' on C:\Users\SRoy\x\qwerty\qwerty.csproj...
Restore succeeded.

PS C:\Users\SRoy\x> ls

    Directory: C:\Users\SRoy\x

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        1/28/2021   1:46 PM                qwerty

PS C:\Users\SRoy\x> cd .\qwerty\
PS C:\Users\SRoy\x\qwerty> dotnet build
Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Users\SRoy\x\qwerty\qwerty.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk.BlazorWebAssembly' specified could not be found.

Build FAILED.

C:\Users\SRoy\x\qwerty\qwerty.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk.BlazorWebAssembly' specified could not be found.
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.23
PS C:\Users\SRoy\x\qwerty>

dotNetPS

javiercn commented 3 years ago

@sroy2020 thanks for the additional details.

@pranavkm do you know what can be going on here?

pranavkm commented 3 years ago

There's a couple of SDK issues for this error code: https://github.com/dotnet/sdk/issues/10229, https://github.com/dotnet/msbuild/issues/2532. Can you look at the solutions posted in these issues to see if it helps?

sroy2020 commented 3 years ago

Hi,

I can't believe it. Using the info from dotnet/sdk#10229. I found out that the env. var. MSBuildSDKsPath was set to a previous SDK. I updated it to "C:\Program Files\dotnet\sdk\5.0.102\Sdks" and now "dotnet build" is fine.

Thanks to all

ghost commented 3 years ago

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

HarrisonOfTheNorth commented 3 years ago

Although seemingly resolved on Windows, I am getting this same original bug on Mac.

Checking the $PATH, I get:

echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands

The project builds properly if built in Visual Studio, however not using the command line.

My specific error is:

error MSB4236: The SDK 'Microsoft.NET.Sdk.BlazorWebAssembly' specified could not be found.

and yet the path to the SDK is: /usr/local/share/dotnet/sdk/5.0.102/Sdks/Microsoft.NET.Sdk.BlazorWebAssembly