【轉】msdev & devenv 的命令列用法(以編譯BerkeleyDB為例) 收藏
最近編譯chrome,vs開啟chrome後不停地更新智能提示,很佔資源,所以查查在命令列編譯vs工程的方法。最近wince工程也要自動編譯,所以也需要在命令列編譯vddproj檔案。
轉自:http://blog.chinaunix.net/u2/89624/showart_1903053.html
msdev是visual studio 6.0的IDE程式, devenv是visual studio 2005的IDE程式
兩種IDE程式, 既可以工作在圖形模式下,也可以工作在命令模式下.
其中, 直接運行msdev 和 devenv將開啟vs6和vs2005的IDE介面. 命令列則支援不同的選項.
Msdev的命令列用法:
Usage:
MSDEV [myprj.dsp|mywksp.dsw] - load project/workspace
[] - load source file
/? - display usage information
/EX - execute a VBScript macro
/OUT - redirect command line output to a file
/USEENV - ignore tools.options.directories settings
/MAKE [] [...] - build specified target(s)
[ - ]
[[|ALL] - [DEBUG|RELEASE|ALL]]
/CLEAN - delete intermediate files but don't build
/REBUILD - clean and build
/NORECURSE - don't build dependent projects
比如我對BerkeleyDB而言, 4.7.25內建了一個Berkeley_DB.dsw, 此工程檔案由包含很多的子項目.
編譯所有項目Debug版本為:
msdev Berkeley_DB.dsw /make "all - Win32 Debug x86"
其中有一個project有許多其他projects組成,就是build_all, 包含了C/C++的動態庫,各種工具程式,還有各種樣本程式. 編譯此project Debug版本就為:
msdev Berkeley_DB.dsw /make "build_all - Win32 Debug x86"
如果還想編譯Java的動態庫, 在vc6中設定好java後, 運行如下命令即可:
msdev Berkeley_DB.dsw /make "db_java - Win32 Debug x86"
在工程檔案外,還有一個用來衡量效能的程式, test_micro,編譯該程式的命令為:
msdev test_micro.dsp /make "test_micro - Win32 Debug x86"
即,對於專案檔而言, 其只有一個project, 就是其本身.
對於自動化程式而言, msdev有一個弊端,就是程式傳回值. 當專案檔/工程檔案不存在的時候, msdev的傳回值居然是0!, 和編譯成功的一樣, 也許msdev認為不存在就是成功吧.
devenv命令的格式就長了一點, 基本文法是:
devenv [solutionfile | projectfile | anyfile.ext] [switches]
比如, 為了方便VC2005以上的編譯, BerkeleyDB將會同時提供vc6所用的dsw檔案同時, 也會推出一個sln檔案,這sln檔案就是solutionfile
使用此檔案編譯BerekleyDB預設配置的Debug版本為:
devenv Berkeley_DB.sln /build "Debug|Win32"
只編譯db的動態庫則為:
devenv Berkeley_DB.sln /build "Debug|Win32" /project db
編譯test_micro則複雜點,因為vc2005預設的project file是.vcproj的,而不是.dsp格式的,而test_micro只有.dsp格式的故而,需要先轉化為.vcproj格式的, 可以用VCBuild工具:
VCBuild test_micro.dsp /upgrade
這樣就產生了test_micro.vcproj
用devenv編譯就是:
devenv test_micro.vcproj /build "Debug x86|Win32"
之所有配置與上面不同在與, test_micro中是適用於VC6的配置, 轉化過來以後, 配置是保留的.
與msdev不同, devenv將檔案不存在視為編譯失敗. 更加適合程式處理.
附:devenv的命令列協助
Microsoft (R) Visual Studio Version 8.0.50727.762.
Copyright (C) Microsoft Corp 1984-2005. All rights reserved.
Use:
devenv [solutionfile | projectfile | anyfile.ext] [switches]
The first argument for devenv is usually a solution file or project file.
You can also use any other file as the first argument if you want to have the
file open automatically in an editor. When you enter a project file, the IDE
looks for an .sln file with the same base name as the project file in the
parent directory for the project file. If no such .sln file exists, then the
IDE looks for a single .sln file that references the project. If no such single
.sln file exists, then the IDE creates an unsaved solution with a default .sln
file name that has the same base name as the project file.
Command line builds:
devenv solutionfile.sln /build solutionconfig [ /project projectnameorfile [ /projectconfig name ] ]
Available command line switches:
/Build Builds the solution or project with the specified solution
configuration. For example "Debug". If multiple platforms
are possible, the configuration name must be enclosed in quotes
and contain platform name. For example: "Debug|Win32".
/Clean Deletes build outputs.
/Command Starts the IDE and executes the command.
/Deploy Builds and then deploys the specified build configuration.
/Edit Opens the specified files in a running instance of this
application. If there are no running instances, it will
start a new instance with a simplified window layout.
/LCID Sets the default language in the IDE for the UI.
/Log Logs IDE activity to the specified file for troubleshooting.
/NoVSIP Disables the VSIP developer's license key for VSIP testing.
/Out Appends the build log to a specified file.
/Project Specifies the project to build, clean, or deploy.
Must be used with /Build, /Rebuild, /Clean, or /Deploy.
/ProjectConfig Overrides the project configuration specified in the solution
configuration. For example "Debug". If multiple platforms are
possible, the configuration name must be enclosed in quotes
and contain platform name. For example: "Debug|Win32".
Must be used with /Project.
/Rebuild Cleans and then builds the solution or project with the
specified configuration.
/ResetAddin Removes commands and command UI associated with the specified Add-in.
/ResetSettings Restores the IDE's default settings, optionally resets to
the specified VSSettings file.
/ResetSkipPkgs Clears all SkipLoading tags added to VSPackages.
/Run Compiles and runs the specified solution.
/RunExit Compiles and runs the specified solution then closes the IDE.
/SafeMode Launches the IDE in safe mode loading minimal windows.
/Upgrade Upgrades the project or the solution and all projects in it.
A backup of these files will be created as appropriate. Please
see Help on 'Visual Studio Conversion Wizard' for more
information on the backup process.
Product-specific switches:
/debugexe Open the specified executable to be debugged. The
remainder of the command line is passed to this
executable as its arguments.
/useenv Use PATH, INCLUDE, LIBPATH, and LIB environment variables
instead of IDE paths for VC++ builds.
To attach the debugger from the command line, use:
VsJITDebugger.exe -p
本文來自CSDN部落格,轉載請標明出處:http://blog.csdn.net/chief1985/archive/2009/08/28/4491650.aspx