现在的位置: 首页 > 综合 > 正文

将VS2008的工程转换(降级)为VS2005的工程(C++)

2013年12月13日 ⁄ 综合 ⁄ 共 1050字 ⁄ 字号 评论关闭

今天在研究google protobuffer(PB)源码时,发现其提供的工程里有一个linux下的批处理“convert2008to2005.sh”,作用是将VS2008的工程及解决方案转换(降级)为VS2005的工程及解决方案。贴出来看看:

#! /bin/sh -e

# This script downgrades MSVC 2008 projects to MSVC 2005 projects, allowing
# people with MSVC 2005 to open them.  Otherwise, MSVC 2005 simply refuses to
# open projects created with 2008.  We run this as part of our release process.
# If you obtained the code direct from version control and you want to use
# MSVC 2005, you may have to run this manually.  (Hint:  Use Cygwin or MSYS.)

for file in *.sln; do
  echo "downgrading $file..."
  sed -i -re 's/Format Version 10.00/Format Version 9.00/g;
              s/Visual Studio 2008/Visual Studio 2005/g;' $file
done

for file in *.vcproj; do
  echo "downgrading $file..."
  sed -i -re 's/Version="9.00"/Version="8.00"/g;' $file
done

# Yes, really, that's it.

说白了,很简单,就是将解决方案(.sln)中的“Format Version 10.00”替换为“Format Version 9.00”,将“Visual Studio 2008”替换为“Visual Studio 2005”,然后将工程(.vcproj)中的“Version="9.00"”替换为“Version="8.00"”即可。明白了原理后,知道该怎么做了吧?对了,就是用文本编辑工具(例如Uedit)将以上替换完成即可。

有偷懒的同学,可能会问,能不能在windows下直接运行以上脚本?答案是不能直接运行,但可以装一个Cygwin来虚拟一个linux环境,从而实现在windows下运行linux shell脚本的功能。有兴趣的同学可以试试看(顺便也可以熟悉一下Cygwin)。以下是我的运行记录:

抱歉!评论已关闭.