Can I code and compile all type of Visual Studio Application from Command line?

后端 未结 3 1704
长发绾君心
长发绾君心 2021-01-06 12:43

I am in the very first step of using Emacs as my programming environment. I run it in DOS Prompt using emacs -nw and do the development there. It\'s quite unbel

3条回答
  •  遥遥无期
    2021-01-06 13:15

    In another answer to this question, @akira said:

    All you have to do is launch the visual-studio-commandline prompt OR incorporate the environment of that prompt into your own shell/powershell/emacs-environment. Have a look at the vcvars32.bat file and what it does; it is located somewhere in the installation folder of visual2008.

    Taking that suggestion, I have created an Emacs lisp file to set up my environment in Emacs for Visual Studio 2010. To create this file, I first captured the environment settings from an ordinary command prompt and then did the same from the Visual Studio Command Prompt:

    set > set_ordinary.txt
    set > set_vs2010.txt
    

    Then, I found the differences between the two using a file differencing tool for Windows. The following emacs lisp code is the result of my effort. Just copy its content into your .emacs file, or better, save its content to vcvars32-2010.el and place it in your 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
    

提交回复
热议问题