question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can I change the path for the MSBuild that gets used?

See original GitHub issue

Environment data

dotnet --info output: Runtime Environment: OS Name: ubuntu OS Version: 17.04 OS Platform: Linux RID: ubuntu.17.04-x64

Microsoft .NET Core Shared Framework Host

Version : 2.0.0-preview2-25407-01 Build : 40c565230930ead58a50719c0ec799df77bddee9

VS Code version: 1.16 (insiders) C# Extension version: 1.12.1

Steps to reproduce

Try opening a C# project based on MSBuild and that used the new Sdks feature.

Expected behavior

I expected omnisharp to load the project since I have MSBuild installed with all the relevant SDKs. Building using the msbuild command works perfectly.

Actual behavior

Omnisharp fails to load the project (that targets net461) since it used its own internal MSBuild without the SDKs installed.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
DustinCampbellcommented, Aug 21, 2017

Yes, OmniSharp definitely supports that syntax.

Yes, you can have a global omnisharp.json file. See this article.

Note that the MSBuild in the latest Mono will build .NET Core-style projects for full framework. This is how we build omnisharp-roslyn on OSX and Linux, which targets net46. It’s as easier as running msbuild OmniSharp.sln

1reaction
jon-sullycommented, Jan 19, 2019

Hey @DustinCampbell, apologies to bring up an old topic here but wanted to ask a similarly related question for probably a very different reason.

I use .NET Core on a Mac and use asdf for version management of many other tools on my machine since most of those tools don’t support having multiple versions installed concurrently. I understand that .NET Core does support multiple versions being installed concurrently on a single machine and that you can further control which is used where with the global.json files, but I’d really like to keep asdf as my single tool for other tools’ version management, and asdf does support .NET Core. It works everywhere as I’d expect (dotnet on CLI resolves fine etc.) except with Omnisharp in VS Code, as the OmniSharp.MSBuild.Discovery.MSBuildLocator only finds the instance of MSBuild that ships with the OmniSharp extension. I see above you mentioning that I can tell it to look at a particular install of MSBuild via an omnisharp.json file, but I want it to leverage a dynamic link rather than a single static installation, effectively. I’m curious for advice on this, but also I am a bit curious as to what Omni uses MSBuild for, because everything in my VS Code environment does appear to still work and operate fine. It would appear I can still do most things normally. Context below:


In case it’s of any relevance asdf stores particular version installs under ~/.asdf/installs/dotnet-core/<version>/

Omni trace

Starting OmniSharp server at 1/19/2019, 2:04:58 PM
    Target: /Users/jonsullivan/source/repos/console-app

OmniSharp server started.
    Path: /Users/jonsullivan/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/run
    PID: 64456

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on MacOS 10.14 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 15.0 - "/Users/jonsullivan/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to '/Users/jonsullivan/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin/MSBuild.dll'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 15.0 - "/Users/jonsullivan/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin"
            MSBuildExtensionsPath = /Users/jonsullivan/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild
            BypassFrameworkInstallChecks = true
            CscToolPath = /Users/jonsullivan/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin/Roslyn
            CscToolExe = csc.exe
            MSBuildToolsPath = /Users/jonsullivan/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/Users/jonsullivan/source/repos/console-app'.
[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
        No solution files found in '/Users/jonsullivan/source/repos/console-app'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/jonsullivan/source/repos/console-app/console-app.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/Users/jonsullivan/source/repos/console-app'.
[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 '/Users/jonsullivan/source/repos/console-app' on host 63566.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/jonsullivan/source/repos/console-app/console-app.csproj
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file '/Users/jonsullivan/source/repos/console-app/console-app.csproj'.
/Users/jonsullivan/source/repos/console-app/console-app.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk' specified could not be found.  /Users/jonsullivan/source/repos/console-app/console-app.csproj
  at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject (System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, System.Object[] args) [0x00040] in <2338fdb301034c1d9c6b95e564d514b0>: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 <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1] (Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, T1 arg0) [0x00000] in <2338fdb301034c1d9c6b95e564d514b0>: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, System.Boolean throwOnFileNotExistsError) [0x00254] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImports (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x00024] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].EvaluateImportElement (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x0000d] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].PerformDepthFirstPass (Microsoft.Build.Construction.ProjectRootElement currentProjectOrImport) [0x000e6] in <2338fdb301034c1d9c6b95e564d514b0>: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 <2338fdb301034c1d9c6b95e564d514b0>: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 <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.Project.Reevaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x0004c] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00034] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation) [0x00000] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00023] in <2338fdb301034c1d9c6b95e564d514b0>: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 <2338fdb301034c1d9c6b95e564d514b0>: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 <2338fdb301034c1d9c6b95e564d514b0>: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 <2338fdb301034c1d9c6b95e564d514b0>: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 <2338fdb301034c1d9c6b95e564d514b0>: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 <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion) [0x000f5] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.String toolsVersion) [0x00000] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore (System.String filePath) [0x0003f] in <46c04c65986d41159ea03c6835eb767f>:0 
  at OmniSharp.MSBuild.ProjectLoader.BuildProject (System.String filePath) [0x0000d] in <46c04c65986d41159ea03c6835eb767f>:0 
  at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load (System.String filePath, OmniSharp.MSBuild.ProjectLoader loader) [0x00015] in <46c04c65986d41159ea03c6835eb767f>:0 
  at OmniSharp.MSBuild.ProjectManager+<>c__DisplayClass25_0.<LoadProject>b__0 () [0x00000] in <46c04c65986d41159ea03c6835eb767f>: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 <46c04c65986d41159ea03c6835eb767f>:0 

[fail]: OmniSharp.MSBuild.ProjectManager
        Attemped to update project that is not loaded: /Users/jonsullivan/source/repos/console-app/console-app.csproj
[info]: OmniSharp.OmniSharpWorkspace
        Miscellaneous file: /Users/jonsullivan/source/repos/console-app/Program.cs added to workspace

dotnet --info

.NET Core SDK (reflecting any global.json):
 Version:   2.2.103
 Commit:    8edbc2570a

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.14
 OS Platform: Darwin
 RID:         osx.10.14-x64
 Base Path:   /Users/jonsullivan/.asdf/installs/dotnet-core/2.2.103/sdk/2.2.103/

Host (useful for support):
  Version: 2.2.1
  Commit:  878dd11e62

.NET Core SDKs installed:
  2.2.103 [/Users/jonsullivan/.asdf/installs/dotnet-core/2.2.103/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.1 [/Users/jonsullivan/.asdf/installs/dotnet-core/2.2.103/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.1 [/Users/jonsullivan/.asdf/installs/dotnet-core/2.2.103/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.2.1 [/Users/jonsullivan/.asdf/installs/dotnet-core/2.2.103/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

Appreciate any help you might be able to offer!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Path to MSBuild - Stack Overflow
To see what gets used if you type msbuild at the command line, do this: where msbuild . If that's not reporting the...
Read more >
Customize your build - MSBuild - Microsoft Learn
You can add a new property to every project by defining it in a single file called Directory.Build.props in the root folder that...
Read more >
The MSBuild path is not changed when running vcvarsall.bat ...
Also notice the double slash in the path. Running MSBuild from the command line Process Explorer can be used to verify that the...
Read more >
Using Standard MSBuild Paths with Visual Studio 2019
For Visual Studio 2019, the first two paths with a \Professional directory differ based on your edition of Visual Studio. As appropriate, you...
Read more >
How do I run MSBuild from the command line using Windows ...
Right-clicking on Computer · Click Properties · Then click Advanced system settings on the left navigation bar · On the next dialog box...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found