Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project fails to load, SDK 'Microsoft.NET.Sdk.Razor' not found #2604

Open
fogzot opened this issue Oct 12, 2018 · 46 comments

Comments

Projects
None yet
@fogzot
Copy link

commented Oct 12, 2018

I know there are other issues with the same behavior but they mostly refer to MacOS and the fix seems to be to install an up to date Mono. The issue I am experiencing happens on Linux, with the latest version of Mono installed.

Environment data

dotnet --info output:

.NET Core SDK (reflecting any global.json):
 Version:   2.1.403
 Commit:    04e15494b6

Runtime Environment:
 OS Name:     debian
 OS Version:  
 OS Platform: Linux
 RID:         debian-x64
 Base Path:   /usr/share/dotnet/sdk/2.1.403/

Host (useful for support):
  Version: 2.1.5
  Commit:  290303f510

.NET Core SDKs installed:
  2.1.403 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

VS Code version:

Version: 1.28.1
Commit: 3368db6750222d319c851f6d90eb619d886e08f5
Date: 2018-10-11T18:09:20.566Z
Electron: 2.0.9
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Architecture: x64

C# Extension version:

1.16.2

Mono version:

Mono JIT compiler version 5.16.0.179 (tarball Thu Oct  4 10:24:32 UTC 2018)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	Interpreter:   yes
	LLVM:          yes(3.6.0svn-mono-/)
	GC:            sgen (concurrent by default)

Steps to reproduce

Just load any project with latest version on Linux. The exception is always the same:

Starting OmniSharp server at 10/12/2018, 10:02:57 AM
    Target: /home/fog/Customers/ventana/yes3/Yes.sln

OmniSharp server started with Mono 5.16.0.
    Path: /home/fog/.vscode/extensions/ms-vscode.csharp-1.16.2/.omnisharp/1.32.5/omnisharp/OmniSharp.exe
    PID: 9601

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on debian 0.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Mono 15.0 - "/usr/lib/mono/msbuild/15.0/bin"
            2: StandAlone 15.0 - "/home/fog/.vscode/extensions/ms-vscode.csharp-1.16.2/.omnisharp/1.32.5/omnisharp/msbuild/15.0/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Mono 15.0 - "/usr/lib/mono/msbuild/15.0/bin"
            CscToolPath = /home/fog/.vscode/extensions/ms-vscode.csharp-1.16.2/.omnisharp/1.32.5/omnisharp/msbuild/15.0/Bin/Roslyn
            CscToolExe = csc.exe
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/home/fog/Customers/ventana/yes3'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.WorkspaceInitializer
        Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
[info]: OmniSharp.MSBuild.ProjectSystem
        Detecting projects in '/home/fog/Customers/ventana/yes3/Yes.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/home/fog/Customers/ventana/yes3/backoffice/Backoffice.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/home/fog/Customers/ventana/yes3'.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /home/fog/Customers/ventana/yes3/backoffice/Backoffice.csproj
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location '/home/fog/Customers/ventana/yes3' on host 9448.
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file '/home/fog/Customers/ventana/yes3/backoffice/Backoffice.csproj'.
/home/fog/Customers/ventana/yes3/backoffice/Backoffice.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk.Razor' specified could not be found.  /usr/lib/mono/msbuild/15.0/bin/Sdks/Microsoft.NET.Sdk.Web/Sdk/Sdk.props
  at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject (System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, System.Object[] args) [0x00040] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Shared.ProjectErrorUtilities.VerifyThrowInvalidProject[T1] (System.Boolean condition, System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, T1 arg0) [0x00003] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1] (Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, T1 arg0) [0x00000] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImportsFromUnescapedImportExpressionConditioned (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement, System.Collections.Generic.List`1[Microsoft.Build.Construction.ProjectRootElement]& projects, Microsoft.Build.BackEnd.SdkResolution.SdkResult& sdkResult, System.Boolean throwOnFileNotExistsError) [0x0024e] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImports (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement, Microsoft.Build.BackEnd.SdkResolution.SdkResult& sdkResult) [0x00027] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].EvaluateImportElement (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x0000d] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].PerformDepthFirstPass (Microsoft.Build.Construction.ProjectRootElement currentProjectOrImport) [0x00209] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].EvaluateImportElement (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x00040] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].PerformDepthFirstPass (Microsoft.Build.Construction.ProjectRootElement currentProjectOrImport) [0x000e6] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].Evaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingService, Microsoft.Build.Framework.BuildEventContext buildEventContext) [0x00103] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].Evaluate (Microsoft.Build.Evaluation.IEvaluatorData`4[P,I,M,D] data, Microsoft.Build.Construction.ProjectRootElement root, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, System.Int32 maxNodeCount, Microsoft.Build.Collections.PropertyDictionary`1[T] environmentProperties, Microsoft.Build.BackEnd.Logging.ILoggingService loggingService, Microsoft.Build.Evaluation.IItemFactory`2[S,T] itemFactory, Microsoft.Build.Evaluation.IToolsetProvider toolsetProvider, Microsoft.Build.Evaluation.ProjectRootElementCache projectRootElementCache, Microsoft.Build.Framework.BuildEventContext buildEventContext, Microsoft.Build.Execution.ProjectInstance projectInstanceIfAnyForDebuggerOnly, Microsoft.Build.BackEnd.SdkResolution.ISdkResolverService sdkResolverService, System.Int32 submissionId, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x0001a] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Evaluation.Project.Reevaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x0004c] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00034] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation) [0x00000] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00023] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Evaluation.Project.Initialize (System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00126] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x0009e] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00000] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00000] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection) [0x00000] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion) [0x000f7] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.String toolsVersion) [0x00000] in <63bca7756d124ea392a81ca1b2d26b9c>:0 
  at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore (System.String filePath) [0x0003e] in <99f3a3b619ce4010a7d6d489ffd5bcf1>:0 
  at OmniSharp.MSBuild.ProjectLoader.BuildProject (System.String filePath) [0x0000d] in <99f3a3b619ce4010a7d6d489ffd5bcf1>:0 
  at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load (System.String filePath, OmniSharp.MSBuild.ProjectLoader loader) [0x00015] in <99f3a3b619ce4010a7d6d489ffd5bcf1>:0 
  at OmniSharp.MSBuild.ProjectManager+<>c__DisplayClass25_0.<LoadProject>b__0 () [0x00000] in <99f3a3b619ce4010a7d6d489ffd5bcf1>:0 
  at (wrapper delegate-invoke) System.Func`1[System.ValueTuple`3[OmniSharp.MSBuild.ProjectFile.ProjectFileInfo,System.Collections.Immutable.ImmutableArray`1[OmniSharp.MSBuild.Logging.MSBuildDiagnostic],OmniSharp.MSBuild.Notification.ProjectLoadedEventArgs]].invoke_TResult()
  at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject (System.String projectFilePath, System.Func`1[TResult] loader) [0x0001b] in <99f3a3b619ce4010a7d6d489ffd5bcf1>:0 

[fail]: OmniSharp.MSBuild.ProjectManager
        Attemped to update project that is not loaded: /home/fog/Customers/ventana/yes3/backoffice/Backoffice.csproj
@rchande

This comment has been minimized.

Copy link
Contributor

commented Oct 12, 2018

@fogzot Do non-Razor projects work (eg dotnet new console)?

@anticide

This comment has been minimized.

Copy link

commented Oct 12, 2018

I had a similar issue, but solved it. Try adding this to your PATH variable (.bashrc, .zshrc...):

MSBuildSDKsPath=/path/to/dotnet/sdk
# export MSBuildSDKsPath=/opt/dotnet/sdk/2.1.403/Sdks
# export PATH=$MSBuildSDKsPath:$PATH

I'm on Arch, so you'll probably need to modify the path.

@Marshal313

This comment has been minimized.

Copy link

commented Oct 14, 2018

@anticide 's method worked for me.
MSBuildSDKsPath="/usr/share/dotnet/sdk/2.1.403/Sdks/" on Ubuntu
Though before I changed it, I noticed the path to Mono Sdks (instead of DotNet Sdks) was being used by Omnisharp.

As you can see in the exception's message, The following path was used : "/usr/lib/mono/msbuild/15.0/bin/Sdks/Microsoft.NET.Sdk.Web/Sdk/Sdk.props"

I don't know how omnisharp works in depth, But I think the problem is that Omnisharp (or maybe even msbuild, not sure) either doesn't know whether to use Mono or dotnet for a project, Or maybe it's just some Path variable conflict.

Note : I haven't tried it, But I think another workaround is to remove your Mono Sdks 😁 Though that's not a wise choice if you're gonna need it.

@humamAbedrabbo

This comment has been minimized.

Copy link

commented Oct 14, 2018

i had this problem on ubuntu 18.04, when i installed mono-complete and mono-develop after installing dotnet core.
When i removed mono, and reinstall apt-transport-https from dotnet, the problem disappeared

@fogzot

This comment has been minimized.

Copy link
Author

commented Oct 15, 2018

@fogzot Do non-Razor projects work (eg dotnet new console)?

Yes. If the project doesn't contain a reference to the Web SDK (not explicitly the Razor one, just Web) everything works.

@fogzot

This comment has been minimized.

Copy link
Author

commented Oct 15, 2018

I can confirm that setting MSBuildSDKsPath to the .NET Core sdks directory fixes the issue.

@anticide

This comment has been minimized.

Copy link

commented Oct 15, 2018

A better solution would be:

export MSBuildSDKsPath=/opt/dotnet/sdk/$(dotnet --version)/Sdks

This way you don't have to update SDK's version.

@anorborg

This comment has been minimized.

Copy link

commented Oct 15, 2018

Has there ever been an explanation of this? I see this error pop up fairly regularly around msbuild sdk resolution. Here is a similar issue logged over there: microsoft/msbuild#2532. Should setting MSBuildSDKsPath be required? Is there a corruption of some installation of the tooling?

@Marshal313

This comment has been minimized.

Copy link

commented Oct 16, 2018

The problem is, that msbuild is also used by mono IDEs like MonoDevelop, So the previous path which is set to Mono SDKs (instead of dotnet SDKs) may be required by an IDE that compiles Mono code. I haven't tried, But setting MSBuildSDKsPath may indeed conflict with mono IDEs.

I'll check to see if it happens and update this comment asap.
If it does, Perhaps a better way is to add the following in VS Code's launch script :

For Ubuntu users :
export MSBuildSDKsPath=/usr/share/dotnet/sdk/$(dotnet --version)/Sdks/

For Arch users :
export MSBuildSDKsPath=/opt/dotnet/sdk/$(dotnet --version)/Sdks

UPDATE : I tested a simple console project using MonoDevelop 7 (FlatPack version though), and there was no problem. Since the issue is closed and continued on other places I'll be watching them now.

@nguerrera

This comment has been minimized.

Copy link

commented Oct 16, 2018

There are a few things at play here. Let me give some background on how this is supposed to work. When MSBuild encounters <Project Sdk=...>, <Import Sdk=...> or <Sdk ...>, it calls into its SdkResolvers. These are plugins that live alongside MSBuild. One in particular, Microsoft.DotNet.MSBuildSdkResolver, resolves Sdks from the .NET Core SDK location based on dotnet being on PATH. There is also a default resolver that looks in MSBuildSdksPath. The default resolver is used if the plugin resolvers are not present or fail to find the Sdk in question. (* Technically, there is a priority given to each resolver and default resolver can go in between plugins, but the priorities aren't assigned that way in practice.)

This error indicates that the default resolver was used to locate the Web SDK (because its Sdk.props is not in a .NET Core SDK location, but rather in the default MSBuildSdksPath), but then it failed to find the Razor SDK in the same default location:

Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk.Razor' specified could not be found.  /usr/lib/mono/msbuild/15.0/bin/Sdks/Microsoft.NET.Sdk.Web/Sdk/Sdk.props

So the first issue I see is that this mono msbuild is bundling Microsoft.NET.Sdk.Web without its Microsoft.NET.Sdk.Razor dependency. This means that the default sdk resolver will never be able to load web projects. Mono msbuild should bundle Microsoft.NET.Sdk.Razor if it is going to bundle Microsoft.NET.Sdk.Web in its default MSBuildSdksPath.

This default resolver would only be used if Microsoft.DotNet.MSBuildSdkResolver failed, which would happen in some normal circumstances:

  • The .NET Core SDK is not installed
  • The .NET Core SDK's dotnet is not on the PATH
  • There is a global.json specifying a .NET Core SDK version that cannot be found.

From other hints above, these do not seem to apply here, but those are still the first things to check.

The next thing to verify is that the mono msbuild being used has Microsoft.DotNet.MSBuildSdkResolver in . /usr/lib/mono/msbuild/15.0/bin/SdkResolvers.

Finally, if it does, then there may be a bug in Microsoft.DotNet.MSBuildSdkResolver, which would fall on me. You can get the resolver to trace info to stderr by setting COREHOST_TRACE=1 as demonstrated at #1849 (comment)

cc @akoeplinger @radical

@nguerrera

This comment has been minimized.

Copy link

commented Oct 16, 2018

So the first issue I see is that this mono msbuild is bundling Microsoft.NET.Sdk.Web without its Microsoft.NET.Sdk.Razor dependency.

See also microsoft/msbuild#3829

@rchande

This comment has been minimized.

Copy link
Contributor

commented Oct 16, 2018

@nguerrera Thanks for the detailed explanation! @anorborg @fogzot Can you try looking through the items Nick suggested to help us figure out what the problem is?

@marek-safar

This comment has been minimized.

Copy link

commented Oct 17, 2018

@nguerrera great analysis! We are now tracking this issue on Mono side as well

@fogzot

This comment has been minimized.

Copy link
Author

commented Oct 19, 2018

@nguerrera thank you for the explanation.
@rchande I think the problem is that OmniSharp uses msbuild from the Mono distribution and Mono doesn't include Microsoft.NET.Sdk.Razor. I don't know why but when Mono msbuild is used, this part of the process doesn't hold true:

One in particular, Microsoft.DotNet.MSBuildSdkResolver, resolves Sdks from the .NET Core SDK location based on dotnet being on PATH.

Because my .NET Core SDK dotnet executable is in path but gets completely ignored.

@rchande

This comment has been minimized.

Copy link
Contributor

commented Oct 23, 2018

@marek-safar Do you have an issue number we can track?

@rchande

This comment has been minimized.

Copy link
Contributor

commented Oct 23, 2018

@marek-safar Never mind, I see you linked it above :)

@deepak-khopade-isdr

This comment has been minimized.

Copy link

commented Oct 25, 2018

@marek-safar, is there any way I can use older version of mono than 5.16.0 Stable which I can use on Ubuntu 16.04. I am still on .NET Core 1.1.0 with few projects added as a references which are full .NET 4.6.2 versions.
This all use to build properly with my Rider on Ubuntu; but after installing new mono, its breaking now.
Any help until above issues resolved with latest mono would be a great help. Thanks.

@marek-safar

This comment has been minimized.

Copy link

commented Oct 25, 2018

You'd need to check your package manager manual. If I remember correctly on Ubuntu you should be able to do something like sudo apt-get install mono-complete=<version> to downgrade automatically.

@akoeplinger

This comment has been minimized.

Copy link

commented Oct 25, 2018

For .deb-based distributions you'd need to use the snapshot repositories we provide: https://www.mono-project.com/docs/getting-started/install/linux/#accessing-older-releases

E.g. for Ubuntu 16.04 it'd be:

# remove existing stable mono
sudo apt remove mono-complete
sudo rm /etc/apt/sources.list.d/mono-official-stable.list

# add 5.14 snapshot repo
echo "deb https://download.mono-project.com/repo/ubuntu stable-xenial/snapshots/5.14.0 main" | sudo tee /etc/apt/sources.list.d/mono-official-snapshot.list
sudo apt update
sudo apt install mono-complete
@deepak-khopade-isdr

This comment has been minimized.

Copy link

commented Oct 26, 2018

@TheBuzzSaw

This comment has been minimized.

Copy link

commented Nov 26, 2018

Note : I haven't tried it, But I think another workaround is to remove your Mono Sdks grin Though that's not a wise choice if you're gonna need it.

I was having tons of issues. (Running Arch.) I gave this a go, and my problems vanished. @Marshal313 you are my hero. Seriously, why is having Mono installed from the repos such a source of problems? :(

@jsoques

This comment has been minimized.

Copy link

commented Nov 27, 2018

This started to happen to me on Windows 10!! I was able to solve also by setting the environment variable MSBuildSDKsPath to point to the latest sdks folder (in my case, C:\Program Files\dotnet\sdk\2.1.500\Sdks)

@damianpawski

This comment has been minimized.

Copy link

commented Nov 28, 2018

Having the same issue on Windows 10, setting up the MSBuildSDKsPath did not work for me.
I am using SDK 2.1.500

@ThisDrunkDane

This comment has been minimized.

Copy link

commented Nov 29, 2018

This happens on my system too, I'm running Manjaro (Arch)

@high-on-communism

This comment has been minimized.

Copy link

commented Dec 3, 2018

Another sad user of Manjaro having the same issue over here...

@trejjam

This comment has been minimized.

Copy link

commented Dec 8, 2018

I had the same issue in Rider, I solve it configuring .Net binary as /opt/dotnet/dotnet. Configuring MSBuildSDKsPath didn't help

@boumanb

This comment has been minimized.

Copy link

commented Dec 24, 2018

I am running Manjaro (Arch)
Following fixed it for me:

export MSBuildSDKsPath=/opt/dotnet/sdk/$(dotnet --version)/Sdks
sudo -E bash -c 'echo $MSBuildSDKsPath'
@marchy

This comment has been minimized.

Copy link

commented Dec 27, 2018

Fixed in Mono 5.18.0.

Thanks guys!

@CarlosJader

This comment has been minimized.

Copy link

commented Dec 31, 2018

I got almost the same error as described. I'm on Win7. After a long time I'm back to learning Unity, got very upset cause I was used to MonoDevelop, it worked greatly. I spent all day trying to make autocomplete work properly. Tried Visual Studio, Sublime3 and Visual Studio Code, or autocomplete wouldn't work at all or it just worked for a couple of seconds... I understand things had to change but I think they should have planned it better, would be cool to have a built-in editor, like installed together with Unity and really read to go. I'm pretty sure it's trivial for experienced users but for a new student, to struggle to do something that should be simple work correctly is highly discourageous...
As suggested I'm downloading the Mono 5.18.0 Preview version right now, hope it works.

Edit:

Installing Mono 5.18.0 didn't work for me.

This is the entire output:

Starting OmniSharp server at 12/31/2018, 10:37:06 AM
Target: c:\Unity\Projects\Survival Shooter\Survival Shooter\Survival Shooter.sln

OmniSharp server started.
Path: C:\Users\Win 7.vscode\extensions\ms-vscode.csharp-1.17.1.omnisharp\1.32.8\OmniSharp.exe
PID: 10032

Starting OmniSharp on Windows 6.1.7601.65536 (x64)
info: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: StandAlone 15.0 - "C:\Users\Win 7.vscode\extensions\ms-vscode.csharp-1.17.1.omnisharp\1.32.8\msbuild\15.0\Bin"
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
MSBUILD_EXE_PATH environment variable set to 'C:\Users\Win 7.vscode\extensions\ms-vscode.csharp-1.17.1.omnisharp\1.32.8\msbuild\15.0\Bin\MSBuild.exe'
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: StandAlone 15.0 - "C:\Users\Win 7.vscode\extensions\ms-vscode.csharp-1.17.1.omnisharp\1.32.8\msbuild\15.0\Bin"
CscToolExe = csc.exe
CscToolPath = C:\Users\Win 7.vscode\extensions\ms-vscode.csharp-1.17.1.omnisharp\1.32.8\msbuild\15.0\Bin\Roslyn
MSBuildExtensionsPath = C:\Users\Win 7.vscode\extensions\ms-vscode.csharp-1.17.1.omnisharp\1.32.8\msbuild
MSBuildToolsPath = C:\Users\Win 7.vscode\extensions\ms-vscode.csharp-1.17.1.omnisharp\1.32.8\msbuild\15.0\Bin
info: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in 'c:\Unity\Projects\Survival Shooter\Survival Shooter'.
info: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
info: OmniSharp.WorkspaceInitializer
Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
info: OmniSharp.MSBuild.ProjectSystem
Detecting projects in 'c:\Unity\Projects\Survival Shooter\Survival Shooter\Survival Shooter.sln'.
info: OmniSharp.MSBuild.ProjectManager
Queue project update for 'c:\Unity\Projects\Survival Shooter\Survival Shooter\Assembly-CSharp.csproj'
info: OmniSharp.MSBuild.ProjectManager
Queue project update for 'c:\Unity\Projects\Survival Shooter\Survival Shooter\Assembly-CSharp-Editor.csproj'
info: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in 'c:\Unity\Projects\Survival Shooter\Survival Shooter'.
info: OmniSharp.MSBuild.ProjectManager
Loading project: c:\Unity\Projects\Survival Shooter\Survival Shooter\Assembly-CSharp.csproj
info: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
info: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
info: OmniSharp.WorkspaceInitializer
Configuration finished.
info: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location 'c:\Unity\Projects\Survival Shooter\Survival Shooter' on host 9196.
fail: OmniSharp.MSBuild.ProjectLoader
The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file 'c:\Unity\Projects\Survival Shooter\Survival Shooter\Assembly-CSharp.csproj'.
c:\Unity\Projects\Survival Shooter\Survival Shooter\Assembly-CSharp.csproj
C:\Users\Win 7.vscode\extensions\ms-vscode.csharp-1.17.1.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1126,5): Error: The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

Loading project: c:\Unity\Projects\Survival Shooter\Survival Shooter\Assembly-CSharp-Editor.csproj
fail: OmniSharp.MSBuild.ProjectLoader
The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file 'c:\Unity\Projects\Survival Shooter\Survival Shooter\Assembly-CSharp-Editor.csproj'.
c:\Unity\Projects\Survival Shooter\Survival Shooter\Assembly-CSharp-Editor.csproj
C:\Users\Win 7.vscode\extensions\ms-vscode.csharp-1.17.1.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1126,5): Error: The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

Attemped to update project that is not loaded: c:\Unity\Projects\Survival Shooter\Survival Shooter\Assembly-CSharp.csproj
fail: OmniSharp.MSBuild.ProjectManager
Attemped to update project that is not loaded: c:\Unity\Projects\Survival Shooter\Survival Shooter\Assembly-CSharp-Editor.csproj

The csproj files are there, it just can't see them.

This part cought my attention since I have .NET v4.7.2 installed.
"The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed."
Couldn't install v4.5 nor uninstall v4.7.2 (tried uninstalling lots of times, uninstalling ends, it says its gone, but its always there, restarted pc several times after uninstalling and its always the same)

I'm noob but if I understood correctly there should be a way to target app to my .NET version?
If so, how can I do that? (I'm using VSCode)

@evs-chris

This comment has been minimized.

Copy link

commented Dec 31, 2018

I can confirm that setting MSBuildSDKsPath resolved the issue for me on Ubuntu 18.04 using the dotnet-sdk snap. For those using the snap, it might be easier to just let the dotnet bin fill in the base path:

export MSBuildSDKsPath=`dotnet --info | grep 'Base Path' | sed -re 's/[^\/]*(.*)/\1/g'`/Sdks

which, I'd guess would work just fine for non-snap versions of dotnetcore.

@rchande

This comment has been minimized.

Copy link
Contributor

commented Jan 2, 2019

@CarlosJader I don't think the problem you're encountering is related to this one. Please file a new issue so we can help you troubleshoot.

@flaviotsales

This comment has been minimized.

Copy link

commented Jan 24, 2019

I'm using Manjaro and setting MSBuildSDKsPath dit not solve the issue. What did solve the issue for me was copying ths Sdks folder to mono/msbuild/15.0/bin, in my case,
cp -r /opt/dotnet/sdk/2.2.103/Sdks /usr/lib/mono/msbuild/15.0/bin
After that, OmniSharp complained about the NugetFallbackFolder, which I created in /opt/dotnet/sdk.
mkdir /opt/dotnet/sdk/NugetFallbackFolder
Now OmniSharp doens't complain about anything and I can build my projects appropriately.

@Charly6596

This comment has been minimized.

Copy link

commented Feb 4, 2019

I'm running Manjaro, the MSBuildSDKsPath solution didn't work for me, nor installing msbuild-stable,
but cp -r /opt/dotnet/sdk/2.2.103/Sdks /usr/lib/mono/msbuild/15.0/bin worked, doesn't seem a proper solution.. but it works 🤷‍♂

EDIT: the MSBuildSDKsPath solution worked, read what @ehouarn-perret said below if you're having issues

@ehouarn-perret

This comment has been minimized.

Copy link

commented Feb 5, 2019

@Charly6596 actually the solution given by @anticide works: export MSBuildSDKsPath=/opt/dotnet/sdk/$(dotnet --version)/Sdks

But you have to persist that change for every new bash instance, therefore you can put that at the end of your .bashrc file along with what is needed for the local self-signed certificate (for proper https support in your local environment):

export MSBuildSDKsPath=/opt/dotnet/sdk/$(dotnet --version)/Sdks
export PATH="$PATH:/home/manjaro/.dotnet/tools"

I managed to have everything working with a Manjaro 18.02 Gnome edition on a live session.
I had some other prior issues to that one: #2837

Baby steps (similar to my other issue resolution in the link above)

  • Install yay to enjoy AUR without struggling with the command line: sudo pacman -Sy yay

  • Setup everything you need (aka the .NET Core SDK, Mono, MSBuild and Visual Studio Code Insiders): yay -S dotnet-sdk mono binutils msbuild-stable visual-studio-code-insiders --noconfirm
    yay -S dotnet-sdk mono binutils msbuild-stable visual-studio-code-bin --noconfirm (see my second post after that one below).

    • Note: binutils cause the Gnome variant does not seem to embed that one natively, and this require for stripping in one of the steps of the msbuild-stable installation.
  • Add the required environment variables that you would like to export at the end of your .bashrc file in your home folder:

    • export MSBuildSDKsPath=/opt/dotnet/sdk/$(dotnet --version)/Sdks
    • export PATH="$PATH:/home/manjaro/.dotnet/tools"
  • Create a dummy project: dotnet new mvc

  • Start Visual Studio Code Insiders: code-insiders .

  • Install the C# extension
    CTRL + SHIFT + P
    ext install ms-vscode.csharp

  • Download the .NET Code Debugger for the C# extension (if needed / not already done the first time)
    CTRL + SHIFT + P
    Debug: Download .NET Core Debugger

  • Generate the launch.json and tasks.json files (if not already answered yes to the popup shows: "Would you like to add the required assets to build and debug your project?")
    CTRL + SHIFT + P
    .NET: Generate Assets for Build and Debug

  • Install the tools for the development self-signed certificate
    dotnet tool install --global dotnet-dev-certs

  • Register the development self-signed certificate:
    dotnet dev-certs https

  • Debugging (.NET Core Launch (web))
    CTRL + SHIFT + D
    F5

@Charly6596

This comment has been minimized.

Copy link

commented Feb 6, 2019

@ehouarn-perret Thanks a lot, I fixed it with the following steps,

  • Uninstall mono, msbuild-stable and dotnet-sdk
  • yay -S dotnet-sdk mono msbuild-stable
  • Replace what i had in .bashrc related to dotnet, copy pasting this:
export MSBuildSDKsPath=/opt/dotnet/sdk/$(dotnet --version)/Sdks
export PATH="$PATH:/home/manjaro/.dotnet/tools"

I had export PATH="$PATH:$MSBuildSDKsPath"

@ehouarn-perret

This comment has been minimized.

Copy link

commented Feb 6, 2019

@Charly6596 glad to know that my solution could help you out

@ehouarn-perret

This comment has been minimized.

Copy link

commented Feb 11, 2019

Playing over and over I've noticed that the insiders is not necessary: I explain everything here, in my SO answer update:

[UPDATE] The official Visual Code AUR page shows the different versions available:

The following packages provide VSCode:

  • code (open-source release)
  • visual-studio-code-bin AUR (Microsoft-branded release)
  • code-git AUR (in-development open-source version)

I think I may have had installed the wrong version at first (the non insiders one was the open source release: code.

Actually when playing with the official tar.gz from the website (which is the hard way equivalent of installing visual-studio-code-bin) it worked fine.

The right way is to (obviously) go with the official Microsoft branded release: visual-studio-code-bin.

@ehouarn-perret

This comment has been minimized.

Copy link

commented Feb 22, 2019

Does not work anymore after the last update: https://aur.archlinux.org/packages/visual-studio-code-bin

@nguerrera

This comment has been minimized.

Copy link

commented Feb 25, 2019

@akoeplinger @marek-safar Are there distributions of mono that include msbuild, but not Microsoft.DotNet.MSBuildSdkResolver?

@nguerrera

This comment has been minimized.

Copy link

commented Feb 25, 2019

I'd like to get to the bottom of why folks are resorting to setting MSBuildSdksPath. See dotnet/cli#10865. They end up breaking themselves with every SDK update. This should not be necessary as I've explained in #2604 (comment).

EDIT: dotnet/cli#10865 was on Windows so was probably set for a different reason, but I'm still curious about why folks are needing to set this on some Linux installations.

@marek-safar

This comment has been minimized.

Copy link

commented Feb 25, 2019

Are there distributions of mono that include msbuild, but not Microsoft.DotNet.MSBuildSdkResolver?

@radical ?

@radical

This comment has been minimized.

Copy link

commented Feb 25, 2019

@directhex might be able to answer this.

@directhex

This comment has been minimized.

Copy link

commented Feb 25, 2019

Yes: RHEL 6.

There are three pieces in play: Microsoft.DotNet.MSBuildSdkResolver.dll (from msbuild.git), libhostfxr.so (from core-setup.git), and the rest of msbuild.git. The package dependency chain is msbuild ➡️ msbuild-libhostfxr ➡️ msbuild-sdkresolver

In the case of our RHEL/CentOS 6 repository, the msbuild-libhostfxr package is intentionally empty (because it cannot compile, because the available version of g++ is too old), and does not depend on msbuild-sdkresolver since it's not functional without libhostfxr.so

I haven't re-examined this mess since 2017, maybe things have changed since then to allow the relevant library to compile with RHEL 6's neolithic g++. It's using a git snapshot of core-setup from 2017-07-06.

@ptrwis

This comment has been minimized.

Copy link

commented Mar 18, 2019

Setting MSBuildSDKsPath solved my problem on Fedora (vscode, .net core3 p3), but IMO a hint to set it should be added to .net core download page:
https://dotnet.microsoft.com/download/thank-you/dotnet-sdk-3.0.100-preview3-linux-x64-binaries
There are instructions to set PATH and DOTNET_ROOT but there is no advice to set MSBuildSDKsPath.
So ultimately:

export DOTNET_ROOT=$HOME/dotnet
export PATH=$PATH:$DOTNET_ROOT
export MSBuildSDKsPath=$DOTNET_ROOT/sdk/$(dotnet --version)/Sdks
@CTJansson

This comment has been minimized.

Copy link

commented Apr 24, 2019

I seem to be doing this wrong, still not very familiar with arch-based Linux (Antergos) yet, so basically I take this export string and paste it into the terminal and press enter and it should just work?
export MSBuildSDKsPath=/opt/dotnet/sdk/$(dotnet --version)/Sdks
Why I think I'm doing wrong it's because code still telling me the sdks can't be found, would probably need a how-to for dummies. Using visual-studio-code-bin from AUR.

@anticide

This comment has been minimized.

Copy link

commented Apr 24, 2019

I seem to be doing this wrong, still not very familiar with arch-based Linux (Antergos) yet, so basically I take this export string and paste it into the terminal and press enter and it should just work?
export MSBuildSDKsPath=/opt/dotnet/sdk/$(dotnet --version)/Sdks

No, you do need to add that line to your .bash_profile file, then reload it with: source ~/.bash_profile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.