Skip to content

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

Closed

Description

@lgmguto

I'm trying to build a solution using msbuild command line and I keep getting this error:

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

The version of msbuild is the latest from microsoft visual studio 2017 tools. I'm using Windows Server 2012 R2 and the project uses .NET Core 2.0.

This is the command that I'm using:

msbuild.exe /p:Configuration=Release /t:restore C:\Projects\MyProject.sln

Activity

  1. fanicia commented on Oct 11, 2017

    @fanicia

    I fixed this by creating a path variable "MSBuildSDKsPath" with the value
    "C:\Program Files\dotnet\sdk\2.0.0\Sdks"

    I don't know why msbuild can't find this path by default, but this fixed the issue for us

  2. DNF-SaS commented on Oct 13, 2017

    @DNF-SaS

    Same here on Win7

  3. DustinCampbell commented on Nov 9, 2017

    @DustinCampbell
    Member

    Anyone who's still having trouble here, could you try unsetting MSBuildSDKsPath and see if the issue still repros. If it does, could you set COREHOST_TRACE=1, reproduce the issue, and then paste the trace output here?

  4. mayconpires commented on Nov 10, 2017

    @mayconpires

    @fanicia thank you!!!

  5. DustinCampbell commented on Nov 10, 2017

    @DustinCampbell
    Member

    @mayconpires : Any chance you could try setting COREHOST_TRACE=1 per my comment above to give us some data about why this is happening?

  6. fanicia commented on Nov 10, 2017

    @fanicia

    @DustinCampbell i just tried unchecking the variable on one of our CI servers.... and now it works without it ???

    I have changed a bunch of stuff on there since i wrote the comment though, so idk :P

  7. greenmooseSE commented on Nov 10, 2017

    @greenmooseSE

    I still have the issue for v15.4.8.50001 but setting COREHOST_TRACE=1 does not make any difference in the console output for msbuild.exe.

    *Edit:
    Initially dotnet build solution.sln resulted in same error in output (but still reported 'Build succeeded'). When trying with above COREHOST_TRACE, dotnet build spit out tons of log output I could not redirect to a file and now, for whatever reason, dotnet build solution.sln works fine. Invoking msbuild.exe directly still causes the same error (on server2, on server1 it works fine for same solution).

    (I also get error MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found, furthermore we had sdk junction paths in for C:\Program Files (x86)\Microsoft Visual Studio\2017\MsBuild\15.0\Sdks and ...\MsBuild\Sdks which both had target to C:\Program Files\dotnet\sdk\1.0.1\Sdks (1.0.1 had been uninstalled), I removed the 2 junction folders and repaired vs2017 build tools, reinstalled netCore 2.0.2 and rebooted. Still same issue.)

  8. fanicia commented on Nov 10, 2017

    @fanicia

    To clarify. I was also in the case where i was able to build with dotnet build, but msbuild /t:rebuild didn't work

  9. nguerrera commented on Nov 10, 2017

    @nguerrera
    Contributor

    I still have the issue for v15.4.8.50001 but setting COREHOST_TRACE=1 does not make any difference in the console output for msbuild.exe.

    This suggests to me that your msbuild.exe copy does not have the following:

    C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\SdkResolvers\Microsoft.DotNet.MSBuildSdkResolver

  10. nguerrera commented on Nov 10, 2017

    @nguerrera
    Contributor
  11. nguerrera commented on Nov 10, 2017

    @nguerrera
    Contributor

    Make sure to install the .NET Core workload:

    image

  12. nguerrera commented on Nov 10, 2017

    @nguerrera
    Contributor

    Workload selection applies to full VS as well:

    image

  13. nguerrera commented on Nov 10, 2017

    @nguerrera
    Contributor

    If you have Build tools SKU:

    • You cannot get Microsoft.NET.Sdk or Microsoft.NET.Sdk.Web to resolve without the .NET Core workload installed.

    If you have full VS:

    • You can get Microsoft.NET.Sdk to resolve without the .NET Core or ASP.NET workloads installed, but it will be locked to version 1.x instead of resolving the latest version or global.json implied version.

    • You cannot get Microsoft.NET.Sdk.Web to resolve without the .NET Core workload or ASP.NET workloads installed.

  14. fanicia commented on Nov 10, 2017

    @fanicia

    @nguerrera I am using the buildtools, not the full VS. Meaning the .Net Core cross-platform development you have highligted

  15. nguerrera commented on Nov 10, 2017

    @nguerrera
    Contributor

    Meaning the .Net Core cross-platform development you have highligted

    ... are installed?

  16. 33 remaining items

  17. cyberkito commented on Aug 23, 2019

    @cyberkito

    I used my local installation

    1. Path Variable MSBuildSDKsPath

    @bigswede74 What is PATH and what is MSBuildSdksPath?

    Do you have C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\SdkResolvers\Microsoft.DotNet.MSBuildSdkResolver ?

    I used my local VS 2017 installation and copied resolver to build server and problem was fixed.

  18. uciprian commented on Sep 16, 2019

    @uciprian

    Tried first MSBuildSdksPath no success
    Updated the build tools 2017 to latest version did not work also
    Copying my local VS 2017 C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\SdkResolvers to build server solved for me the issue also!

    Ideally an update for build tools for visual studio 2017 package should fix this

  19. rainersigwald commented on Sep 16, 2019

    @rainersigwald
    Member

    @uciprian do you have the ".NET Core Build Tools" workload enabled for your build tools installation?

  20. added a commit that references this issue on Sep 17, 2019
  21. devel0 commented on Sep 17, 2019

    @devel0

    I stumbled into this problem today, building an app that use roslyn, here there is a repro repository with a Dockerfile based upon mcr.microsoft.com/dotnet/core/sdk:3.0.100-rc1-bionic image.

    The program tries to analyze a simple console test source and generate warning at this line, following is the execution of the docker image that can be built and run using this script contained in the repository

    Successfully tagged repros/netcore-roslyn-01:latest
    ------------ENTRYPOINT
    3.0.100-rc1-014190 [/usr/share/dotnet/sdk]
    dotnet executable = [/usr/bin/dotnet]
    PATH              = [/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin]
    DOTNET_ROOT       = [/usr/share/dotnet]
    MSBuildSDKsPath   = [/usr/share/dotnet/sdk/3.0.100-rc1-014190/Sdks]
    ---> OpenProject
    Msbuild failed when processing the file '/src/test/test.csproj' with message: The imported project "/app/Current/Microsoft.Common.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.  /usr/share/dotnet/sdk/3.0.100-rc1-014190/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.props
    ---> GetCompilation
    has documents = False
    

    UPDATE

    fixed by adding MSBUILD_EXE_PATH ( see here )

  22. epgeroy commented on Oct 9, 2019

    @epgeroy

    I ran OmniSharp with COREHOST_TRACE=1 as suggested by @DustinCampbell and could see the following messsage

    Searching SDK directory in [/usr/local/bin]
    --- Resolving SDK version from SDK dir [/usr/local/bin/sdk]
    Checking if resolved SDK dir [/usr/local/bin/sdk/-1.-1.-1] exists
    It was not possible to find any SDK version
    

    FWIW, on my machine, dotnet in installed in /usr/lib64/dotnet and has a link in /usr/bin.
    I looked inside the /usr/local/bin directory and found a dead symbolic link /opt/dotnet. I removed the symbolic link, and MSBuild now properly resolves the SDK.

    I did all kind of stuff, this is the only thing that worked form me

  23. saeedtabrizi commented on Dec 6, 2019

    @saeedtabrizi

    I ran OmniSharp with COREHOST_TRACE=1 as suggested by @DustinCampbell and could see the following messsage

    Searching SDK directory in [/usr/local/bin]
    --- Resolving SDK version from SDK dir [/usr/local/bin/sdk]
    Checking if resolved SDK dir [/usr/local/bin/sdk/-1.-1.-1] exists
    It was not possible to find any SDK version
    

    FWIW, on my machine, dotnet in installed in /usr/lib64/dotnet and has a link in /usr/bin.
    I looked inside the /usr/local/bin directory and found a dead symbolic link /opt/dotnet. I removed the symbolic link, and MSBuild now properly resolves the SDK.

    This Works Like a charm . Thanks

  24. cwhsu1984 commented on Mar 1, 2020

    @cwhsu1984

    add environment variables MSBuildSDKsPath with value "C:\Program Files\dotnet\sdk\2.0.0\Sdks" does not work for me.

    copy SdkResolvers from local to build server works for me

  25. mkonars commented on Mar 3, 2020

    @mkonars

    For me it worked by running dotnet build instead of using msbuild

  26. atniomn commented on Jul 22, 2020

    @atniomn

    @venkateswaris

    If you install via choco, you need to include workloads you would normally include via the GUI:

    #2532 (comment)

    For me, I used this choco command:

    choco install visualstudio2019buildtools --package-parameters "--allWorkloads --includeRecommended --includeOptional --passive --locale en-US"
    
  27. igitur commented on Mar 20, 2022

    @igitur

    Anyone who's still having trouble here, could you try unsetting MSBuildSDKsPath and see if the issue still repros.

    This solved it for me, because previously I had a mixture of standard dotnet SDK installs (via Visual Studio), but also via scoop package manager. I had since removed scoop's version, but the environment variable was still pointing to the scoop directory. Just deleting the MSBuildSDKsPath environment variable thus solved it for me.

    It would have been nice if the tool output this:
    error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found IN THIS FREEKING DIRECTORY: C:\asdf\asdf\asdf\

  28. adelriosantiago commented on Sep 6, 2022

    @adelriosantiago

    Before adding the MSBuildSDKsPath env variable you might first want to see if the dotnet.exe is working. You can navigate to where dotnet.exe is (in my case it was "C:\Program Files\dotnet") and then execute the command you want to run. I was able to run dotnet tool install -g csharpier correctly after this. Adding the env variable didn't help.

  29. emz00 commented on Jun 13, 2024

    @emz00

    In my case this error was caused by a nearly empty SDK directory under %ProgramFiles%\dotnet\sdk: dotnet/sdk#41022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions