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

MSBuild "Couldn't load project" because The SDK 'Microsoft.Net.Sdk' specified could not be found #1416

Closed
mickaelistria opened this issue Mar 4, 2019 · 25 comments

Comments

@mickaelistria
Copy link

I'm trying to use OmniSharp 1.32.9 with LSP support in Eclipse aCute (instead of older versions).
I can connect to OmniSharp through LSP, so the connection part seems fine. But OmniSharp logs a failure that make the LS request never receive a response

[Log]	[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        FAILURE: Could not locate '/home/mistria/runtime-New_configurationds(2)/.metadata/.plugins/org.eclipse.acute/omnisharp-roslyn/omnisharp/msbuild/15.0/Bin/Microsoft.Build.resources.dll'.
[Warning]	[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file '/home/mistria/runtime-New_configurationds(2)/NewDotnetProject/NewDotnetProject.csproj'.
[Error]	[fail]: OmniSharp.MSBuild.ProjectManager
        Attempted to update project that is not loaded: /home/mistria/runtime-New_configurationds(2)/NewDotnetProject/NewDotnetProject.csproj

After that, no LSP request receives a response.
The omnisharp/msbuild/15.0/Bin/Microsoft.Build.resources.dll file is indeed not present in any recent package of omnisharp.

@mickaelistria
Copy link
Author

@johnnyasantoss Could it be related to #1349 ?

@bjorkstromm
Copy link
Member

I wonder if omitting .resources here and return null would fix the issue?

@johnnyasantoss
Copy link
Contributor

@johnnyasantoss Could it be related to #1349 ?

@mickaelistria I don't think that it is related to that. What the PR #1349 did was to change the way that Omnisharp searches for MSBuild instances across the system, in a way that it prefers instances that have .net core installed, and disfavors the standalone one. :)

@mickaelistria
Copy link
Author

Last version that was successfully tested for LSP was 1.29.1. I tried some intermediary versions in the meantime, but could see much progress because of #1269 . Latest version should fix #1269 but I'm now stuck by this issue.

With 1.29.1 too, msbuild 15.0 is included and I don't see the Microsoft.Build.resources.dll file, but it doesn't fail.
So it seems to me that the issue is not in the packaging but rather than the MSBuild detection has a bug and looks (and fails) for non-existent files; while it was working fine with the same environment in 1.29.1 (and maybe later, but I can't bisect with my use-case because of #1269).

@mickaelistria
Copy link
Author

On Slack, @demelev mentions

Yesterday the friend of mine got it worked on ArchLinux, he didn’t report about such an error.
try to find where those dlls are `fd Microsoft.Build.resources /usr`
on my machine they are at ‘/usr/local/share/dotnet/sdk/2.1.301/en/Microsoft.Build.resources.dll’

So I removed my current dotnet installation (that did not contain the Microsoft.Build.resources.dll) and reinstalled the fresh one (which does contain this dll).
But nothing changes, the msbuild location is still resolving to the msbuild folder inside OmniSharp which misses the Microsoft.Build.resources.dll and then fails.

@demelev: are you using directly the content of the omnisharp-linux-x64.zip folder or are you using something else or tweaking the content?

@mickaelistria
Copy link
Author

If I fully remove the msbuild folder from the omnisharp-linux-x64 and try it, here is the log I see

[Log]	Starting server...
[Log]	[trce]: OmniSharp.Services.AssemblyLoader
        Assembly loaded: OmniSharp.Cake
[Log]	[dbug]: OmniSharp.CompositionHostBuilder
        Loaded OmniSharp.Cake, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
[Log]	[trce]: OmniSharp.Services.AssemblyLoader
        Assembly loaded: OmniSharp.DotNet
[Log]	[dbug]: OmniSharp.CompositionHostBuilder
        Loaded OmniSharp.DotNet, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
[Log]	[trce]: OmniSharp.Services.AssemblyLoader
        Assembly loaded: OmniSharp.DotNetTest
[Log]	[dbug]: OmniSharp.CompositionHostBuilder
        Loaded OmniSharp.DotNetTest, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
[Log]	[trce]: OmniSharp.Services.AssemblyLoader
        Assembly loaded: OmniSharp.Host
[Log]	[dbug]: OmniSharp.CompositionHostBuilder
        Loaded OmniSharp.Host, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
[Log]	[trce]: OmniSharp.Services.AssemblyLoader
        Assembly loaded: OmniSharp.MSBuild
[Log]	[dbug]: OmniSharp.CompositionHostBuilder
        Loaded OmniSharp.MSBuild, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
[Log]	[dbug]: OmniSharp.CompositionHostBuilder
        Loaded OmniSharp.Plugins, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
[Log]	[trce]: OmniSharp.Services.AssemblyLoader
        Assembly loaded: OmniSharp.Plugins
[Log]	[trce]: OmniSharp.Services.AssemblyLoader
        Assembly loaded: OmniSharp.Roslyn
[Log]	[dbug]: OmniSharp.CompositionHostBuilder
        Loaded OmniSharp.Roslyn, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
[Log]	[trce]: OmniSharp.Services.AssemblyLoader
        Assembly loaded: OmniSharp.Roslyn.CSharp
[Log]	[dbug]: OmniSharp.CompositionHostBuilder
        Loaded OmniSharp.Roslyn.CSharp, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
[Log]	[trce]: OmniSharp.Services.AssemblyLoader
        Assembly loaded: OmniSharp.Script
[Log]	[dbug]: OmniSharp.CompositionHostBuilder
        Loaded OmniSharp.Script, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
[Info]	[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[Log]	[dbug]: OmniSharp.MSBuild.Discovery.Providers.MonoInstanceProvider
        Could not retrieve Mono runtime path
[Info]	[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 0 MSBuild instance(s)
[Error]	[fail]: OmniSharp.CompositionHostBuilder
        Could not locate MSBuild instance to register with OmniSharp
[Log]	[trce]: OmniSharp.Services.AssemblyLoader
        Assembly loaded: Microsoft.CodeAnalysis.Features, Version=2.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
[Log]	[trce]: OmniSharp.Services.AssemblyLoader
        Assembly loaded: Microsoft.CodeAnalysis.CSharp.Features, Version=2.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
[Log]	[trce]: OmniSharp.HostServicesAggregator
        Successfully added Microsoft.CodeAnalysis.Features, Version=2.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 to host service assemblies.
[Log]	[trce]: OmniSharp.HostServicesAggregator
        Successfully added Microsoft.CodeAnalysis.CSharp.Features, Version=2.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 to host service assemblies.
[Error]	[crit]: OmniSharp.Extensions.LanguageServer.LspRequestRouter
        Failed to handle notification initialize
System.NullReferenceException: Object reference not set to an instance of an object
  at OmniSharp.MSBuild.ProjectSystem..ctor (OmniSharp.IOmniSharpEnvironment environment, OmniSharp.OmniSharpWorkspace workspace, OmniSharp.MSBuild.Discovery.IMSBuildLocator msbuildLocator, OmniSharp.Services.IDotNetCliService dotNetCliService, OmniSharp.MSBuild.SdksPathResolver sdksPathResolver, OmniSharp.Services.MetadataFileReferenceCache metadataFileReferenceCache, OmniSharp.Eventing.IEventEmitter eventEmitter, OmniSharp.FileWatching.IFileSystemWatcher fileSystemWatcher, OmniSharp.FileSystem.FileSystemHelper fileSystemHelper, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, System.Collections.Generic.IEnumerable`1[T] eventSinks) [0x00057] in <38374769105b47408aff877b879e5b44>:0 
  at (wrapper dynamic-method) System.Object.lambda_method(System.Runtime.CompilerServices.Closure,System.Composition.Hosting.Core.LifetimeContext,System.Composition.Hosting.Core.CompositionOperation)
  at System.Composition.Hosting.Core.LifetimeContext.GetOrCreate (System.Int32 sharingId, System.Composition.Hosting.Core.CompositionOperation operation, System.Composition.Hosting.Core.CompositeActivator creator) [0x000a8] in <8e026c716fc84f38aae28085eaaee9fc>:0 
  at System.Composition.TypedParts.ActivationFeatures.LifetimeFeature+<>c__DisplayClass1_0.<RewriteActivator>b__0 (System.Composition.Hosting.Core.LifetimeContext c, System.Composition.Hosting.Core.CompositionOperation o) [0x00011] in <9aac21a4a3f24063b2b8b59143acddfc>:0 
  at System.Composition.Hosting.Providers.ImportMany.ImportManyExportDescriptorProvider+<>c__DisplayClass3_2`1[TElement].<GetImportManyDescriptor>b__4 (System.Composition.Hosting.Core.ExportDescriptor e) [0x00006] in <8e026c716fc84f38aae28085eaaee9fc>:0 
  at System.Linq.Enumerable+SelectArrayIterator`2[TSource,TResult].ToArray () [0x00012] in <92922d9bda2f4e1cba9242d052be6d43>:0 
  at System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0001f] in <92922d9bda2f4e1cba9242d052be6d43>:0 
  at System.Composition.Hosting.Providers.ImportMany.ImportManyExportDescriptorProvider+<>c__DisplayClass3_1`1[TElement].<GetImportManyDescriptor>b__3 (System.Composition.Hosting.Core.LifetimeContext c, System.Composition.Hosting.Core.CompositionOperation o) [0x0002b] in <8e026c716fc84f38aae28085eaaee9fc>:0 
  at System.Composition.Hosting.Core.CompositionOperation.Run (System.Composition.Hosting.Core.LifetimeContext outermostLifetimeContext, System.Composition.Hosting.Core.CompositeActivator compositionRootActivator) [0x0001c] in <8e026c716fc84f38aae28085eaaee9fc>:0 
  at System.Composition.Hosting.Core.LifetimeContext.TryGetExport (System.Composition.Hosting.Core.CompositionContract contract, System.Object& export) [0x0001d] in <8e026c716fc84f38aae28085eaaee9fc>:0 
  at System.Composition.Hosting.CompositionHost.TryGetExport (System.Composition.Hosting.Core.CompositionContract contract, System.Object& export) [0x00000] in <8e026c716fc84f38aae28085eaaee9fc>:0 
  at System.Composition.CompositionContext.GetExport (System.Composition.Hosting.Core.CompositionContract contract) [0x00000] in <12675e53c8854b48abd187539ce374db>:0 
  at System.Composition.CompositionContext.GetExports (System.Type exportType, System.String contractName) [0x00023] in <12675e53c8854b48abd187539ce374db>:0 
  at System.Composition.CompositionContext.GetExports[TExport] (System.String contractName) [0x00000] in <12675e53c8854b48abd187539ce374db>:0 
  at System.Composition.CompositionContext.GetExports[TExport] () [0x00000] in <12675e53c8854b48abd187539ce374db>:0 
  at OmniSharp.LanguageServerProtocol.LanguageServerHost.CreateCompositionHost (OmniSharp.Extensions.LanguageServer.Models.InitializeParams initializeParams) [0x0011d] in <12ebd3f7bbcf42e3be4a762fa059501a>:0 
  at OmniSharp.LanguageServerProtocol.LanguageServerHost.Initialize (OmniSharp.Extensions.LanguageServer.Models.InitializeParams initializeParams) [0x00000] in <12ebd3f7bbcf42e3be4a762fa059501a>:0 
  at OmniSharp.Extensions.LanguageServer.LanguageServer+<>c__DisplayClass26_0.<OmniSharp.Extensions.JsonRpc.IRequestHandler<OmniSharp.Extensions.LanguageServer.Models.InitializeParams,OmniSharp.Extensions.LanguageServer.Models.InitializeResult>.Handle>b__0 (OmniSharp.Extensions.LanguageServer.InitializeDelegate c) [0x00000] in <43976da1155b4e5492c57f3d85e24f0e>:0 
  at System.Linq.Enumerable+SelectListIterator`2[TSource,TResult].MoveNext () [0x00048] in <92922d9bda2f4e1cba9242d052be6d43>:0 
  at System.Threading.Tasks.Task.WhenAll (System.Collections.Generic.IEnumerable`1[T] tasks) [0x000c4] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0 
  at OmniSharp.Extensions.LanguageServer.LanguageServer+<OmniSharp-Extensions-JsonRpc-IRequestHandler<OmniSharp-Extensions-LanguageServer-Models-InitializeParams\,OmniSharp-Extensions-LanguageServer-Models-InitializeResult>-Handle>d__26.MoveNext () [0x0005d] in <43976da1155b4e5492c57f3d85e24f0e>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0 
  at OmniSharp.Extensions.LanguageServer.LspRequestRouter+<RouteRequest>d__11.MoveNext () [0x00161] in <43976da1155b4e5492c57f3d85e24f0e>:0 

@mickaelistria
Copy link
Author

@johnnyasantoss

I don't think that it is related to that. What the PR #1349 did was to change the way that Omnisharp searches for MSBuild instances across the system, in a way that it prefers instances that have .net core installed, and disfavors the standalone one. :)

In my case, it seems like the included instance is not found at all, and the the instance that's inside the SDK is found but can't be loaded.
So I believe that the MSBuildLocator isn't properly working in 2 ways (at least in my environment, Fedora 29 + rpm packages from Microosft)

  1. It doesn't detect a local MSBuild while I have dotnet-sdk installed
  2. When it fails back to local MSBuild embedded in OmniSharp, it fails because of the missing Microsoft.Build.resources.dll which seems unnecessary in that context.

I guess item 1. never worked so it's fine it still doesn't, but 2. seems to be a regression caused by #1349

@demelev
Copy link
Contributor

demelev commented Mar 19, 2019

I use omnisharp-osx.tar.gz because I am working on macOS. But right now I get omnisharp-linux-x64.tar.gz from release page and tried it out. When I run it through calling run script it fails.
But if I run as "mono /Users/username/Downloads/omnisharp-linux-x64/omnisharp/OmniSharp.exe -lsp"
it works even on osx.

@mickaelistria
Copy link
Author

If I start OmniSharp with environment variable DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false, hoping it will ignore the .resources.dll (it does!), then I see some more failures later:

[Info]	Registered MSBuild instance: StandAlone 15.0 - "/home/mistria/sandbox/omnisharp-linux-x64/omnisharp/msbuild/15.0/Bin"
            MSBuildExtensionsPath = /home/mistria/sandbox/omnisharp-linux-x64/omnisharp/msbuild
            BypassFrameworkInstallChecks = true
            CscToolPath = /home/mistria/sandbox/omnisharp-linux-x64/omnisharp/msbuild/15.0/Bin/Roslyn
            CscToolExe = csc.exe
            MSBuildToolsPath = /home/mistria/sandbox/omnisharp-linux-x64/omnisharp/msbuild/15.0/Bin
[Info]	Assembly loaded: Microsoft.CodeAnalysis.Features, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
[Info]	Assembly loaded: Microsoft.CodeAnalysis.CSharp.Features, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
[Info]	Attempting to resolve 'Microsoft.CodeAnalysis.VisualBasic.Workspaces, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
[Info]	FAILURE: Could not locate '/home/mistria/sandbox/omnisharp-linux-x64/omnisharp/msbuild/15.0/Bin/Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll'.
[Info]	FAILURE: Could not locate '/home/mistria/sandbox/omnisharp-linux-x64/omnisharp/msbuild/15.0/Bin/Microsoft.CodeAnalysis.VisualBasic.Features.dll'.

@mickaelistria
Copy link
Author

See also #1400 which is about the same issue.

@johnnyasantoss
Copy link
Contributor

@johnnyasantoss

I don't think that it is related to that. What the PR #1349 did was to change the way that Omnisharp searches for MSBuild instances across the system, in a way that it prefers instances that have .net core installed, and disfavors the standalone one. :)

In my case, it seems like the included instance is not found at all, and the the instance that's inside the SDK is found but can't be loaded.
So I believe that the MSBuildLocator isn't properly working in 2 ways (at least in my environment, Fedora 29 + rpm packages from Microosft)

1. It doesn't detect a local MSBuild while I have dotnet-sdk installed

2. When it fails back to local MSBuild embedded in OmniSharp, it fails because of the missing Microsoft.Build.resources.dll which seems unnecessary in that context.

I guess item 1. never worked so it's fine it still doesn't, but 2. seems to be a regression caused by #1349

Do you have msbuild package installed (from mono)?
btw from my experience with Fedora, you will have to find another source to get that package. Fedora repo doesn't provide the latest version of Mono (which includes msbuild). If my memory isn't failing me, it still provides mono 4.8.

I'll create a VM here to see if I can replicate this :)

@mickaelistria
Copy link
Author

I don't have mono installed and don't want to force my users to install mono (we focus on .NET Core), I've installed dotnet-sdk package of .NET Core from Microsoft builds https://dotnet.microsoft.com/download/linux-package-manager/fedora29/sdk-current
The dotnet-sdk seems (I'm not sure) to include an instance of MSBuild, or at least to contain the libraries requested by omnisharp. I would expect this to be detected ideally.
But still, that doesn't resolve the issue why the standalone msbuild instance in the omnisharp folder cannot be loaded properly...

@mickaelistria
Copy link
Author

So I've run omnisharp-1.32.9/run -v --stdio -s . from a new dotnet project (generated with dotnet new console), and I got some more messages

{"Event":"Error","Body":{"Text":"Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk' specified could not be found.  /home/mistria/runtime-New_configurationNET/NewDotnetProject/NewDotnetProject.csproj\n  at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject (System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, System.Object[] args) [0x00040] in <2338fdb301034c1d9c6b95e564d514b0>:0 \n  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 <2338fdb301034c1d9c6b95e564d514b0>:0 \n  at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1] (Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, T1 arg0) [0x00000] in <2338fdb301034c1d9c6b95e564d514b0>:0 \n  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, System.Boolean throwOnFileNotExistsError) [0x00254] in <2338fdb301034c1d9c6b95e564d514b0>:0 \n  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImports (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x00024] in <2338fdb301034c1d9c6b95e564d514b0>:0 \n  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].EvaluateImportElement (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x0000d] in <2338fdb301034c1d9c6b95e564d514b0>:0 \n  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].PerformDepthFirstPass (Microsoft.Build.Construction.ProjectRootElement currentProjectOrImport) [0x000e6] in <2338fdb301034c1d9c6b95e564d514b0>:0 \n  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].Evaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingService, Microsoft.Build.Framework.BuildEventContext buildEventContext) [0x00103] in <2338fdb301034c1d9c6b95e564d514b0>:0 \n  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 <2338fdb301034c1d9c6b95e564d514b0>:0 \n  at Microsoft.Build.Evaluation.Project.Reevaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x0004c] in <2338fdb301034c1d9c6b95e564d514b0>:0 \n  at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00034] in <2338fdb301034c1d9c6b95e564d514b0>:0 \n  at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation) [0x00000] in <2338fdb301034c1d9c6b95e564d514b0>:0 \n  at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00023] in <2338fdb301034c1d9c6b95e564d514b0>:0 \n  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 <2338fdb301034c1d9c6b95e564d514b0>:0 \n  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 <2338fdb301034c1d9c6b95e564d514b0>:0 \n  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 <2338fdb301034c1d9c6b95e564d514b0>:0 \n  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 <2338fdb301034c1d9c6b95e564d514b0>:0 \n  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 <2338fdb301034c1d9c6b95e564d514b0>:0 \n  at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion) [0x000f5] in <2338fdb301034c1d9c6b95e564d514b0>:0 \n  at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.String toolsVersion) [0x00000] in <2338fdb301034c1d9c6b95e564d514b0>:0 \n  at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore (System.String filePath) [0x0003f] in <38374769105b47408aff877b879e5b44>:0 \n  at OmniSharp.MSBuild.ProjectLoader.BuildProject (System.String filePath) [0x0000d] in <38374769105b47408aff877b879e5b44>:0 \n  at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load (System.String filePath, OmniSharp.MSBuild.ProjectLoader loader) [0x00015] in <38374769105b47408aff877b879e5b44>:0 \n  at OmniSharp.MSBuild.ProjectManager+<>c__DisplayClass28_0.<LoadProject>b__0 () [0x00000] in <38374769105b47408aff877b879e5b44>:0 \n  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()\n  at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject (System.String projectFilePath, System.Func`1[TResult] loader) [0x0001b] in <38374769105b47408aff877b879e5b44>:0 ","FileName":"/home/mistria/runtime-New_configurationNET/NewDotnetProject/NewDotnetProject.csproj","Line":1,"Column":1},"Seq":43,"Type":"event"}

and here is the .csproj

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

</Project>

@mickaelistria
Copy link
Author

mickaelistria commented Mar 27, 2019

Similar error is shown for a project generated with dotnet new web. Invoking omnisharp/run on this folder tells me The SDK 'Microsoft.NET.Sdk.Web specified could not be found.

@mickaelistria mickaelistria changed the title Could not locate '<...>/omnisharp/msbuild/15.0/Bin/Microsoft.Build.resources.dll' MSBuild "Couldn't load project" Mar 27, 2019
@mickaelistria mickaelistria changed the title MSBuild "Couldn't load project" MSBuild "Couldn't load project" because The SDK 'Microsoft.Net.Sdk' specified could not be found Mar 27, 2019
@mickaelistria
Copy link
Author

Found out that dotnet/msbuild#2532 (comment) seems to be a valid workaround.

@akshita31
Copy link
Contributor

Hello all,

We recently added some changes that improve how the sdks are discovered. In vscode could you try setting"omnisharp.path": latest and restarting omnisharp ?

@guidovossen
Copy link

This fixed it for me akshita31! thanks. after setting that value to "latest" I saw on startup

Getting latest OmniSharp version information
Downloading package 'Latest OmniSharp Version Information' (1 KB).................... Done!
Installing OmniSharp Version = 3.5.0-beta.2216...
Platform: win32, x86_64

Downloading package 'OmniSharp for Windows (.NET 4.6 / x64), Version = 3.5.0-beta.2216' (32179 KB).................... Done!
Installing package 'OmniSharp for Windows (.NET 4.6 / x64), Version = 3.5.0-beta.2216'

Finished

@ocdogan
Copy link

ocdogan commented Apr 18, 2019

You're breaking something every time. Please test it well.

@filipw
Copy link
Member

filipw commented Apr 18, 2019

You're breaking something every time. Please test it well.

We are sorry about that.

However, opting into "omnisharp.path": "latest" pulls the latest build from the master branch which by its nature may not always be stable (or might be affected by some CI issues), since not every merge is an official supported release. Therefore it's only recommended to use "omnisharp.path": "latest" to check the latest functionality/verify some bugs fixes from OmniSharp etc. but not for long term sustainable usage.

The safer way is to set "omnisharp.path" to one of the versions found here https://github.com/OmniSharp/omnisharp-roslyn/blob/master/CHANGELOG.md, they will be more stable than just taking latest master branch build.

But of course, the safest way is to simply use the version of the OmniSharp that ships with the given editor extension (VS Code, emacs and so on).

Hope this helps.

@ocdogan
Copy link

ocdogan commented Apr 18, 2019

Thanks for the quick response. Than, please test well what you develop before merging to main. An opensource, non-commercial product doesn't have to be a cracking one. I can not call such kind of things as a bug, they are obviously there when the plugin is getting loaded. If you want to keep this to be used, please be careful while coding and test, test, test and test again.

@daveaglick
Copy link

daveaglick commented Apr 18, 2019

@ocdogan

I can not call such kind of things as a bug, they are obviously there when the plugin is getting loaded

Do you have any idea how hard it is to get all the various .NET SDKs, versions of MSBuild, Visual Studio instances, and the rest to play nicely so that when you go to build a project it builds the way you expect? I suspect you don't since as far as I can tell you've never contributed here, but let me tell you it's hard. It's not just a matter of "oh look, there's bug, oh well let's ship anyway!" There are all sorts of independent variables that when combined result in a very, very large set of possible end-user environments and any one of them could end up breaking. Not to mention there's forward compatibility issues when working on build tooling - something that worked fine could break in the future in unanticipated ways when new parts of the build chain are released.

In general I would urge you to have a little more understanding and patience towards the maintainers of OSS projects that you consume and use. I applaud @filipw for his helpful and measured response. Suggesting that the folks who give a lot of time to this project are not "careful" or that they don't "test, test, test and test again" is honestly a little insulting.

@ocdogan
Copy link

ocdogan commented Apr 18, 2019

Sorry all, I think I got misunderstood. I'm a fun of this project and thanks to everyone contributing to it, it's a real success. I'm not trying to ignore the effort behind, I'm just asking for more. Yes, I'm not a contributor of development but as in the nature of using OSS projects somehow we're all becoming testing contributors and being a tester/user must not mean that has to struggle with bugs this regularly. By testing more someone loose a bit more time, but a serious amount of users can save more than that. That's what I just wanted to point and remind this. Please don't take all words personal.

@borgdylan
Copy link

I got the same issue on Linux and I happen to have mono's msbuild manually compiled and isntalled. I added export MSBuildSDKsPath=/usr/local/lib/mono/msbuild/Current/bin/Sdks to my bashrc. The path will be different if installed via packages or manually to a a prefix that is not /usr/local.

@cahlbin
Copy link

cahlbin commented Jul 18, 2019

FYI I ran into a similar issue of projects failing to be loaded, and the error Could not locate ... Microsoft.Build.resources.dll. I run OmniSharp with an Emacs setup on macOS. I was also first confused by the Microsoft.Build.resources.dll error, but turns out the actual issue of the projects failing to load was related to the dotnet executable not being on PATH when the OmniSharp process is started from within Emacs. So, as the macOS .NET SDK install puts the dotnet executable in /usr/local/share/dotnet/dotnet, after adding /usr/local/share/dotnet to PATH it the projects loads OK.

I'm suspecting this has something to do with how Microsoft.DotNet.MSBuildSdkResolver attempts to resolve paths for SDKs based on getting info via the main dotnet CLI executable (if present).

@filipw
Copy link
Member

filipw commented Dec 12, 2019

This should be resolved by now. We switched to MsBuild 16.3 and things are generally a lot better.
On Arch specifically, it's recommended to install Mono 6.6.0.

@filipw filipw closed this as completed Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests