All Articles

Dotnet Development in Emacs

I’m a little past the one year mark of using Emacs as my default text editor/IDE/super organizer, which means I have developed opinions about what I want out of a program (mainly one that will do ALL THE THINGS).

Unfortunately, until now when I’ve been working on C# projects, I’ve had to use either Visual Studio or VS Code, finding some emacs keybindings as a poor add and getting frustrated when said keybindings don’t match up with my emacs config.

Drake VSCode vs Emacs

Well today, that problem has finally been SOLVED!

Here are the steps I followed:

  1. First up, I installed an omnisharp server for emacs based on omnisharp-rosalyn. For the projects I’m currently working on, I’m using the .NET 3.1 SDK, but the omnisharp server should still work with multiple SDKs.

  2. Install Mono (though this may be redundant).

  3. Install Nuget.

  4. Add the following line to your .bashrc or .zshrc:
    alias nuget= "mono /usr/local/bin/nuget.exe"

I use Spacemacs for my Emacs distribution, so I added the following lines to my config file.

dotspacemacs-configuration-layers
'(
  csharp
 )'
 
dotspacemacs-additional-packages
'(
 dotnet
 csproj-mode
 )'
 
(defun dotspacemacs/user-config ()
  (add-hook 'csharp-mode-hook 'dotnet-mode)
)
  1. I installed csproj-mode from Github and dotnet CLI from melpa.

  2. The final bit I needed was to install the nuget packages for my project, so that I’d be able to get all the code completion and syntax checkers for my project. Hypar’s nuget package is still in beta, so it threw errors when I tried to install it using dotnet-mode, but once I provided the correct version number (hypar -v=0.0.1-beta6), it went through.

And now I can get code completion, build, and debug all from Emacs!

Code Completion

Published Nov 28, 2020

Striving to stay curious.