2017-10-05 96 views
1

我有一个包含120个项目的旧MFC解决方案。 现在我试着用VISUALC 2017年编译,但每个项目发出错误:以编程方式更改项目设置

cannot open file mfc140d.lib

打开项目属性,改变平台的工具包,VS2017 141和语言版本的C++ 17点的修复它。 但是为120个项目执行此操作需要花费很长时间,然后对于发布版本也是如此。哪些是项目文件中的设置,我可以通过编程方式更改以设置这两个选项?我肯定找不到它们

+2

如果您选择“所有配置”,而不是单独为“发布”和“调试”单独执行,您只需要点击120次。否则,请对一个项目进行更改,查看.vcxproj文件中的更改内容,然后使用您最喜欢的文本编辑器进行查找/替换。 –

+0

这里的关键是我认为它是.vcproj文件而不是.vcxproj文件,该死的 – Laurijssen

+0

使用[属性页](https://docs.microsoft.com/de-de/cpp/ide/working-与项目的属性#属性 - 网页)。或者,切换到可编程的构建系统,如CMake。每个人都讨厌它(包括我在内),但是没有办法管理复杂的构建系统。或者,稍微改写Stroustrup:只有两种构建系统:大家抱怨的那些,以及没有人使用的那些。 – IInspectable

回答

0

写了一个python脚本,如果不存在,它会将stdcpp17和v141添加到vcxproj文件中。也许有人找到它的用途:

def get_all_files(basedir): 
    for root, subfolders, files in os.walk(basedir): 
     for file in os.listdir(root): 
      yield root, file 

def all_lines_from_file(file): 
    with open(file, 'r') as fd: 
     for line in fd.readlines(): 
      yield line 

def update_VCXPROJ(): 
    standard = '<LanguageStandard>stdcpp17</LanguageStandard>' 
    toolset = '<PlatformToolset>v141</PlatformToolset>' 
    add1 = '<CharacterSet>MultiByte</CharacterSet>' 
    add2 = '<DebugInformationFormat>' 

    for root, file in get_all_files('c:/projects/6thcycle/sources/'): 
     if not file.lower().endswith('.vcxproj'): 
      continue 

     thisfile = '' 
     for line in all_lines_from_file('{0}/{1}'.format(root, file)): 
      if toolset in line or standard in line: 
       continue 

      if add1 in line: 
       line += ' {0}\n'.format(toolset) 
      elif add2 in line: 
       line += '  {0}\n'.format(standard) 

      thisfile += line 

     with open('{0}/{1}'.format(root, file), 'w') as fd: 
      fd.write(thisfile)  

update_VCXPROJ() 
相关问题