Can I code and compile the entire type of Visual Studio application from the command line?

I am in the first phase of using Emacs as my programming environment. I run it in DOS Prompt using emacs -nw and do the development there. It is absolutely unbelievable that I can only encode J2EE and J2ME using Emacs and its Eshell / Shell.

And now about using it to develop Visual Studio. I am currently working in a simple OpenGL application using Visual C ++ .NET 2008. I am not trying to create this application from the command line, is this possible?

If in J2EE and J2ME we had a build.xml file (this is an ant build file), but what is its counterpart in Visual Studio.NET?

I already compiled a simple Visual Studio Console program using the command line. It works, but what about a complete project set ???

Thanks!

+3
source share
3 answers

A lot of comments:

  • You do not need to use -nw ; Emacs works great with windows.

  • The counterpart to build.xml is xxxxxx.sln, in combination with the dependent project files, which are zzzzzzz.csproj. Of course, replace xxxx and zzzzz with your names for solutions and projects.

  • you don't need the eshell or shell command to compile. You can start compilation from emacs using the Mx compile , which is often associated with a keyboard shortcut for easy access. Mine is C-xC-e , but I don't know if this is a broad convention or just my choice.

  • The next-error function works great to move the point to the next error reported by the compiler. You may need a regular expression for error strings. I use this:

    (add-to-list 'compilation-error-regexp-alist-alist' (msvc "^ [\ t] \ ([A-Za-z0-9 \.] [^ (] \. \ (cpp \ | c \ | h \) \) (\ ([0-9] + \)) *: + \ (error \ | fatal error \ | warning \) C [0-9] +: "1 3)))

If you already have an msvc entry, you may need to

 (let ((msvcentry (assoc 'msvc compilation-error-regexp-alist-alist ))) (when msvcentry (setcdr msvcentry '(msvc ....))))) 
  • Cedet. I have no experience using CEDET with C ++ on Windows, but many people use CEDET with C ++ in other environments to complete code, analyze code, this kind of thing.
+2
source

you have several command line tools:

  • msbuild that builds your project from .sln files (which are similar to ant build.xml files)
  • nmake , which is an old nmake system based on Makefile files
  • pure cl.exe and link.exe

all you have to do is run a visual studio command line prompt or disable the prompt environment in your / powershell / emacs -environment shell. look at the vcvars32.bat file and what it does is somewhere in the visual2008 installation folder.

you can also use other build systems ( scons , cmake , etc.) that are either standalone (scons) or create your own scripts for your compiler (cmake will create .sln in your case).

to compile (and link) a simple binary that opengl uses, you can do this:

  % cl /nologo opengl.cpp /link OpenGL32.lib GLu32.lib and GLaux.lib 

take a look at nehe-tutorial .

+5
source

In another answer to this question, @akira said :

All you have to do is run a visual studio-command prompt, OR include the environment for that invitation in your / powershell / emacs -environment shell. Look at vcvars32.bat and what it does; it is located somewhere in the visual2008 installation folder.

Taking this sentence, I created an Emacs lisp file to configure my environment in Emacs for Visual Studio 2010. To create this file, I first grabbed the environment settings from a regular command line, and then did the same with the Visual Studio Command Prompt:

 set > set_ordinary.txt set > set_vs2010.txt 

Then I found the differences between them using the file delimiting tool for Windows . The following emacs lisp code is the result of my efforts. Just copy its contents to the .emacs file or, better, save its contents to vcvars32-2010.el and put it in load-path .

 ;;; vcvars32-2010.el --- Create Visual Studio Command Prompt (2010) environment settings ;; Environment settings for: ;; Visual Studio 2010 Professional ;; Version 10.0.40219.1 SP1Rel ;; ;; Microsoft .NET Framework ;; Version 4.5.50938 SP1Rel ;; Reference: ;; C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\vcvarsall.bat ;; -and- ;; C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\bin\\vcvars32.bat ;;; Usage: ;; Place this file somewhere in your `load-path' and add the following line ;; to your `.emacs' file: ;; ;; (load "vcvars32-2010.el") ;;; Code: (setenv "CommonProgramFiles" "C:\\Program Files\\Common Files") (setenv "DevEnvDir" "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\") (setenv "Framework35Version" "v3.5") (setenv "FrameworkDir" "C:\\Windows\\Microsoft.NET\\Framework\\") (setenv "FrameworkDIR32" "C:\\Windows\\Microsoft.NET\\Framework\\") (setenv "FrameworkVersion" "v4.0.30319") (setenv "FrameworkVersion32" "v4.0.30319") (setenv "INCLUDE" (concat "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\INCLUDE;" "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\INCLUDE;" "C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\include;")) (setenv "LIB" (concat "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\LIB;" "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\LIB;" "C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\lib;")) (setenv "LIBPATH" (concat "C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;" "C:\\Windows\\Microsoft.NET\\Framework\\v3.5;" "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\LIB;" "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\LIB;")) (setenv "Path" (concat "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VSTSDB\\Deploy;" "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\;" "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\BIN;" "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\Tools;" "C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;" "C:\\Windows\\Microsoft.NET\\Framework\\v3.5;" "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\VCPackages;" "C:\\Program Files (x86)\\HTML Help Workshop;" "C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\bin\\NETFX 4.0 Tools;" "C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\bin;" (getenv "Path"))) (setenv "PROCESSOR_ARCHITECTURE" "AMD64") (setenv "ProgramFiles" "C:\\Program Files") (setenv "VCINSTALLDIR" "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\") (setenv "VSINSTALLDIR" "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\") (setenv "WindowsSdkDir" "C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\") ;;; vcvars32-2010.el ends here 
+2
source

Source: https://habr.com/ru/post/1333710/


All Articles