VS2008Express版本环境的Solution批量编译

最近做一个传统老项目,因为Solution太多,考虑做一个代码编译batch工具,起初一看,应该是很简单的问题。

用MSBUILD 做编译顺其自然, 兴致勃勃的将Batch处理文件全部写好,突然放到环境中执行,发现编译出问题。

 而后,对Solution中的Project进行单独编译,仍然报错。考虑编译顺序的情况下,仍旧。后来调查相关继续文档

, 发现是因为MSBUILD时,会将管理引用的所有DLL等相关参照全部进行连接编译。 

 而正好,老系统有一个直接从外部拷贝过来的DLL,编译不会通过。

继续查找解决方案, 可用devenv.exe作编译工具。 然而本机装的是VS2008Express版本,根本没有该EXE

文件。得知,VS2008EXpress版本情况下,用vbexpress.EXE执行文件。随后就是到微软官方网站查询对应的

使用方法。  原理是通过CreateSolutionLists.bat生成对象Solution的List文本文件。

然后 用foreachTest.bat 来做循环执行处理,完成多个Solution的批处理。

 以下是后来做出的bat文件

--- CreateSolutionLists.bat  START----------

set solutionList=C:NACCS_6svnSolutionList.Txt
cd C:NACCS_6svn ewsysProjects
if exist %solutionList% (
   echo Solution list file is existied, please input any key to contiune!
   pause
   forfiles /m *.sln /s >%solutionList%
   echo please check the content of the solutionList file, delete the '"' in the file.
   pause

 --- CreateSolutionLists.bat  END----------

 ------ foreachTest.bat START -----------------

 @echo build start  %date% !!!

@echo off
set startTime=%date%
set vbexpresscmd="C:Program Files (x86)Microsoft Visual Studio 9.0Common7IDEvbexpress"
set inpath=C:NACCS_6svn ewsysProjects
set solutionList=C:NACCS_6svnSolutionList.Txt
set filetime=%time:~0,2%%time:~3,2%%time:~6,2%
set logPath=C:NACCS_6svnlog
for /f "tokens=*" %%a in (%solutionList%) do (
  echo %vbexpresscmd% %inpath%\%%a /build Debug /out %logPath%\%%a_%filetime%.log
  call %vbexpresscmd% %inpath%\%%a /build Debug /out %logPath%\%%a_%filetime%.log
  if exist %logPath%\%%a_%filetime%.log (
     echo error happened!      
     Pause
     )
)
@echo build end finished!!!
@echo start at: %startTime%; Finished at: %date%.
pause

  ------ foreachTest.bat  END-----------------

关联连接

https://msdn.microsoft.com/ja-jp/library/s2h6xst1.aspx 

https://blogs.msdn.microsoft.com/msbuild/2005/11/19/msbuild-in-visual-studio-part-12-compiling-inside-visual-studio/ 

Love it, and you live without it
原文地址:https://www.cnblogs.com/tomclock/p/7426992.html