使用批处理build vs2005的工程

  • VCBuild 
 
@echo off
vcbuild.exe buidTest.sln "Release|Win32"
if errorlevel 1 goto BUILDERROR

echo 成功
goto end

:BUILDERROR
echo 失败

:end 

示例如下: 

@echo off
if not exist "%vs80comntools%vsvars32.bat" goto missing
call "%vs80comntools%vsvars32.bat"

rem call vcbuild.exe your_sln_name.sln "Your Configuration name " /rebuild

echo **  building XXX **
cd .\XXX\xxx
call vcbuild.exe ".\xxxx.vcproj"   "Release|Win32" /rebuild
cd ..\..\..

rem **  xxx items  **
cd .\xxxxcall vcbuild.exe ".\xxxxsln"   "Release|Win32" /rebuild
cd ..\..

goto :eof

:missing
echo the visual studio install is missing.
goto :eof
vcbuild的所有命令如下:
Microsoft (R) Visual C++ Project Builder - Command Line Version 8.00.50727
Copyright (C) Microsoft Corp 1993-2003. All rights reserved.
Usage: vcbuild [options] [project|solution] [config|$ALL]
Options:
/clean (/c)     Clean build outputs only
/error:<str>    Prefix to add to error lines on output to stderr
/errfile:<file> Log all errors to the file specified
/htmllog:<file> Logs output to html file specified
                (default: $(IntDir)\BuildLog.htm)
/implib         Makes an import library for a DLL configuration (does not link)
/info:<str>     Prefix to add to information lines on output to stdout
/link (/l)      Performs a link without building sources
/logcommands    Prints commands and response files to screen
/logfile:<file> Log all output and build information to the file specified
/override:<file>Override the project settings with the settings in the given
                property sheet file
/M<number>      Specifies the number of concurrent builds to run, if possible
/msbuild:<opt>  Pass <opt> to msbuild.exe
/nocolor        Do not output error and warning messages in color
/nohtmllog      Do not write an html build log file
/noimplib       Does not generate an import library.
                NOTE: this option overrides /implib.
/nologo         Suppress version and copyright message
/nondefmsbuild  Do not use the copy of msbuild.exe located in the .NET
                Frameworks installation
/platform:<str> Build only configurations for the given platform
/implibobjs:<s> Additional dependencies for the librarian
/rebuild (/r)   Clean build outputs and perform a build
/forcelink      Forces a link without building sources
/showenv        Show environment in the html build log
/time           Times the build from start to finish
/upgrade        Upgrades the project file to the latest format supported
                NOTE: the upgrade switch does not perform a build
                NOTE: this option is ignored for solution files
/useenv (/u)    Use environment variables for INCLUDE and LIB paths
/wrnfile:<file> Log all warnings to the file specified
/warning:<str>  Prefix to add to warning lines on output to stdout
@<file>         Read options from the specified response file
Default Behavior:
===============================================================================
If no project is specified, and there is only a single .vcproj file in the
directory, that project will be built.
If no configuration is specified, and the VCBUILD_DEFAULT_CFG environment
variable is set, the configuration it specifies will be built. If it is not
set, then all configurations will be built.
The default action is to build the specified configurations without cleaning.
Options will also be read from the VCBUILD_DEFAULT_OPTIONS environment
variable.
===============================================================================

C:\Program Files\Microsoft Visual Studio 8\VC\vcpackages>
  • DEVENV
也可以使用devenv来进行编译
批处理是直接调用Microsoft Visual Studio 8\Common7\IDE\ 目录内的 devenv.exe ,它启动后就是IDE,提供的参数如下:

用法:

devenv [solutionfile | projectfile | anyfile.ext] [switches]

devenv 的第一个参数通常是一个解决方案文件或项目文件。如果您希望在编辑器中自动打开文件,也可以使用任何其他文件作为第一个参数。当您输入项目文件时,IDE会在项目文件的父目录中查找与该项目文件具有相同基名称的 .sln 文件。如果不存在这样的 .sln 文件,IDE 将查找引用该项目的单个 .sln 文件。如果不存在这样的单个.sln 文件,则 IDE 将创建一个具有默认 .sln 文件名且未保存的解决方案,其基名称与项目文件的基名称相同。

命令行编译:

devenv solutionfile.sln /build solutionconfig [ /project projectnameorfile [ /projectconfig name ] ]

 可用的命令行开关:

/Build

使用指定的解决方案配置生成解决方案或

项目。例如“Debug”。如果可能存在多个平台,

则配置名称必须用引号括起来

并且包含平台名称。例如“Debug|Win32

/Clean

删除生成结果。

/Command

启动 IDE 并执行该命令。

/Deploy

生成并部署指定的生成配置。

/Edit

在此应用程序的运行实例中打开

指定文件。如果没有正在运行的实例,

则启动一个具有简化窗口布局的新实例。

/LCID

设置 IDE 中用于用户界面的默认语言。

/Log

IDE 活动记录到指定的文件以用于故障排除。

/NoVSIP

禁用用于 VSIP 测试的 VSIP 开发人员许可证密钥。

/Out

将生成日志追加到指定的文件中。

/Project

指定生成、清理或部署的项目。

必须和 /Build/Rebuild/Clean /Deploy 一起使用。

/ProjectConfig

重写解决方案

配置中指定的项目配置。例如“Debug”。如果可能存在

多个平台,则配置名称必须用引号括起来

并包含平台名称。例如“Debug|Win32

必须和 /Project 一起使用。

/Rebuild

先清理,然后使用指定配置生成

解决方案或项目。

/ResetAddin

移除与特定外接程序关联的命令和命令用户界面。

/ResetSettings

恢复 IDE 的默认设置,还可以重置为

指定的 VSSettings 文件。

/ResetSkipPkgs

清除所有添加到 VSPackages SkipLoading 标记。

/Run

编译并运行指定的解决方案。

/RunExit

编译并运行指定的解决方案然后关闭 IDE

/SafeMode

以安全模式启动 IDE,加载最少数量的窗口。

/Upgrade

升级项目或解决方案以及其中的所有项目。

并相应地创建这些文件的备份。有关备份

过程的更多信息,请参见

Visual Studio 转换向导”上的帮助。

 产品特定的开关:

/debugexe

打开要调试的指定可执行文件。命令行的其余部分作为它的参数传递到此执行文件。

/useenv   

使用PATHINCLUDELIBPATH

 要从命令行附加调试器,请使用:

       VsJITDebugger.exe -p <pid>

 示例代码:

@echo off

if not exist "%vs80comntools%vsvars32.bat" goto missing
call "%vs80comntools%vsvars32.bat"

cd .\Example_\Example_
devenv.com Example_.vcproj /rebuild "release|win32" /out ..\..\output.log
cd ..\..

cd .\TTTT\TTTT
devenv.com TTTT.vcproj /rebuild "release|win32" /out ..\..\output.log

rem build finished
pause

原文地址:https://www.cnblogs.com/ahuo/p/2470175.html