Closed lgmguto closed 5 years ago
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 )
I ran OmniSharp with
COREHOST_TRACE=1
as suggested by @DustinCampbell and could see the following messsageSearching 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
I ran OmniSharp with
COREHOST_TRACE=1
as suggested by @DustinCampbell and could see the following messsageSearching 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
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
For me it worked by running dotnet build
instead of using msbuild
@venkateswaris
If you install via choco, you need to include workloads you would normally include via the GUI:
https://github.com/dotnet/msbuild/issues/2532#issuecomment-343578403
For me, I used this choco command:
choco install visualstudio2019buildtools --package-parameters "--allWorkloads --includeRecommended --includeOptional --passive --locale en-US"
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\
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.
In my case this error was caused by a nearly empty SDK directory under %ProgramFiles%\dotnet\sdk
: https://github.com/dotnet/sdk/issues/41022
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