Skip to content

Instantly share code, notes, and snippets.

@lionicsheriff
Last active October 7, 2016 16:19
Show Gist options
  • Save lionicsheriff/5971015 to your computer and use it in GitHub Desktop.
Save lionicsheriff/5971015 to your computer and use it in GitHub Desktop.
Emacs: Compile visual studio projects from within emacs (M-x compile)
(defun mbg/devenv-compile nil
"Set up compile command for Visual Studio"
(interactive)
(let ((vsvars (shell-quote-argument "C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Common7\\Tools\\vsvars32.bat"))
(solution-file (shell-quote-argument
;; awesomely, locate-dominating-file returns the directory for the file
;; so when you use a pattern to find a file, you need to run it again in
;; the directory itself to get the file name. Who knew.
(car (directory-files
(locate-dominating-file default-directory
(lambda (dir)
(directory-files dir
nil
".*\\.sln$"
t)))
t
".*\\.sln$"))))
(build-config "Debug"))
(message (concat "sln: " solution-file " @ Config: " build-config))
(setq compile-command (concat "call " vsvars " && devenv " solution-file " /Build " build-config))))
@lionicsheriff
Copy link
Author

Usage

  1. M-x mbg/devenv-compile

    this sets up the compile-command

  2. M-x compile

@lionicsheriff
Copy link
Author

TODO

  • add as hook for c# mode
  • set up compilation-error-regexp-alist (as hook for compile-mode)
  • create real repo
  • create elpa package
  • make it easier to switch visual studio versions (auto detect installed?)
  • read sln and provide the list of build configs?
  • read sln and provide a list of projects to build individually?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment