Sublime Forum

C# Setup for Sublime Text 4

#1

Hi all,

I am using Windows 10 and having some C# project using both .NET Framework and .NET Core.

I would like to setup C# development for my C# project.

I tried to use Omnisharp but it does not work.

Please could you help me to setup C# dev environment for my projects?

many thanks

0 Likes

#2

Hi folks,

+1 for C# for Sublime Text 4

Should we wait for it or MSFT do not want to help with that to eliminate the competition with VS Code?

1 Like

#3

There’s both OmniSharp and LSP-OmniSharp available for Sublime Text. Is there something specific that doesn’t work with them? If so, please report them to the respective issue trackers, links to which can be found on Package Control.

2 Likes

#4

Hello. There is a simpler option that does not require any third party apps.
In sublime text go to Tools-Build System-New Build System. And add the following
{
“shell_cmd”: “csc $file_base_name.cs && $file_base_name.exe”
}

And save. Now, when building in the sublime text, the program will build your file and run the .exe.

0 Likes

#5

LSP-Omnisharp provides IntelliSense features only.

Build process for complex projects is controlled by dotnet executable these days (.NET 6+), which also works for .NET 4.x targets.

The most tricky or cumbersome part is just to create/write proper *.csproj project files files with all the settings and dependencies in it and maybe *.sln a solution file. Once those exist dotnet build <solutionfile> is all you need to build your project.

VS Code also just executes the following to compile a project:

dotnet build <solutionfile> /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary
1 Like

#6

tools>build system> new build system>
{
“shell_cmd”: “dotnet run $file_base_name.cs && $file_base_name.exe”
}

0 Likes

#7

Does this mean only C# code analysis (undefined vars, etc) or also completions for .NET Core?

0 Likes

#8

Whatever OmniSharp provides.

Latest LSP-OmniSharp uses latest available Omnisharp .NET6 release, which supports .NET6+.

1 Like

#9

Hello there :smiley:

I’ve found my way in here to figure out if anyone has gotten it working?
My problem is specifically that It’s almost but not quite working,
It has problems finding the definition for built in keywords like enum and object, to me this seems like a reference problem.

My debug message is the following:

Troublshooting Log: Omnisharp
# Troubleshooting: OmniSharp
## Version
 - LSP: 2.2.0
 - Sublime Text: 4180
## Server Test Run
 - exit code: 0
 - output
## Server Configuration
 - command
```json
[
  "C:\\bin\\Sublime Text\\LATEST\\Data\\Package Storage\\LSP-OmniSharp\\OmniSharp.exe",
  "--languageserver",
  "--encoding",
  "utf-8",
  "--hostPID",
  "60616"
]
  • shell command
"C:\bin\Sublime Text\LATEST\Data\Package Storage\LSP-OmniSharp\OmniSharp.exe" --languageserver --encoding utf-8 --hostPID 60616
  • selector
source.cs | source.cake
  • priority_selector
source.cs | source.cake
  • init_options
{}
  • settings
{
  "csharp": {
    "format": {
      "enable": true
    },
    "maxProjectFileCountForDiagnosticAnalysis": 1000,
    "referencesCodeLens": {
      "enabled": true,
      "filteredSymbols": []
    },
    "semanticHighlighting": {
      "enabled": true
    },
    "suppressHiddenDiagnostics": true,
    "testsCodeLens": {
      "enabled": true
    }
  },
  "omnisharp": {
    "defaultLaunchSolution": null,
    "enableAsyncCompletion": false,
    "enableDecompilationSupport": false,
    "enableEditorConfigSupport": true,
    "enableImportCompletion": false,
    "enableMsBuildLoadProjectsOnDemand": false,
    "enableRoslynAnalyzers": false,
    "loggingLevel": "information",
    "maxFindSymbolsItems": 1000,
    "maxProjectResults": 250,
    "minFindSymbolsFilterLength": 0,
    "organizeImportsOnFormat": false,
    "useEditorFormattingSettings": true
  },
  "razor": {
    "format": {
      "enable": true
    }
  }
}
  • env
{
  "FrameworkPathOverride": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\MSBuild\\Current"
}

Active view

  • File name
C:\Code\insights\insights\InsightsBackend.cs
  • Settings
{
  "auto_complete_selector": "meta.tag, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc",
  "lsp_active": true,
  "syntax": "Packages/C#/C#.sublime-syntax"
}
  • base scope
source.cs

Project / Workspace

  • folders
[
  "C:\\Code\\insights"
]
  • is project: True
  • project data:
{
  "folders": [
    {
      "path": "."
    }
  ]
}

LSP configuration

{
  "show_diagnostics_severity_level": 0
}

System PATH

  • C:\Program Files\Amazon Corretto\jdk11.0.20_9\bin
  • C:\Program Files (x86)\Common Files\Oracle\Java\javapath
  • C:\WINDOWS\system32
  • C:\WINDOWS
  • C:\WINDOWS\System32\Wbem
  • C:\WINDOWS\System32\WindowsPowerShell\v1.0\
  • C:\WINDOWS\System32\OpenSSH\
  • C:\Program Files\dotnet\
  • C:\Program Files\Microsoft VS Code\bin
  • C:\Program Files\Microsoft SQL Server\150\Tools\Binn\
  • C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\
  • C:\bin\gh\
  • C:\bin\apache-maven-3.9.6\bin
  • C:\bin\JetBrains\Toolbox\scripts
  • C:\Program Files\Docker\Docker\resources\bin
  • C:\Users\jonas\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts
  • C:\Program Files\nodejs\
  • C:\Program Files\Amazon\AWSCLIV2\
  • C:\Program Files\Git\cmd
  • C:\Program Files\PowerShell\7\
  • C:\Users\jonas\scoop\shims
  • C:\Users\jonas\AppData\Local\Microsoft\WindowsApps
  • C:\Users\jonas.dotnet\tools
  • C:\Users\jonas\AppData\Local\JetBrains\Toolbox\scripts
  • C:\Users\jonas\AppData\Local\Microsoft\WinGet\Links
  • C:\Users\jonas\AppData\Local\GitHubDesktop\bin
  • C:\bin\deno
  • C:\bin\vim\bin\vim91
  • C:\Users\jonas\AppData\Roaming\npm
  • C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin
0 Likes

#10

Maybe caused by "FrameworkPathOverride" environment variable.

It has already been removed from LSP-OmniSharp but that change hasn’t been released yet.

0 Likes