在Appveyor构建之前如何运行VCUpgrade? [英] How to run VCUpgrade before Appveyor build?

查看:132
本文介绍了在Appveyor构建之前如何运行VCUpgrade?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们分发了一组Visual Studio 2010项目文件.用户应根据自己的口味进行升级.我们的 .appveyor.yml文件包括以下图像(除了配置和平台):

We distribute a set of Visual Studio 2010 project files. Users are expected to upgrade to suit their taste. Our .appveyor.yml file includes the following images (in addition to configurations and platforms):

  • Visual Studio 2017
  • Visual Studio 2015
  • Visual Studio 2013
  • Visual Studio 2012
  • Visual Studio 2010

Visual Studio 2017构建失败,原因:

The Visual Studio 2017 build failed with:

Build started
git clone -q --depth=3 --branch=master https://github.com/noloader/cryptopp.git C:\projects\cryptopp
git checkout -qf 3504f1da2591d8b84e356527ed41dc6209eafa06
msbuild "C:\projects\cryptopp\cryptest.sln" /verbosity:minimal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
Microsoft (R) Build Engine version 15.1.1012.6693
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Platform.targets(55,5): error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, please install Visual Studio 2010 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\projects\cryptopp\cryptlib.vcxproj]
Command exited with code 1

感兴趣的文本是:

错误MSB8020:找不到Visual Studio 2010的生成工具(Platform Toolset ='v100').要使用v100生成工具进行生成,请安装Visual Studio 2010生成工具.或者,您可以通过选择项目"菜单或右键单击解决方案,然后选择重新定位解决方案",升级到当前的Visual Studio工具.

error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, please install Visual Studio 2010 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution".

在开发人员命令提示符下工作时,我运行VCUpgrade或使用GitBash和sed -i s'|Tools>v100|Tools>v120' *vcxproj*更改平台工具集.

When I am working from developer command prompts, I run VCUpgrade or I use GitBash and sed -i s'|Tools>v100|Tools>v120' *vcxproj* to change the platform toolset.

当我尝试通过AppVeyor test_script:运行它时,会导致另一个失败.例如,来自 1.0.131构建日志:

When I try to run it through the AppVeyor test_script:, it results in another failure. For example, from the 1.0.131 build log:

...
vcupgrade.exe -nologo -overwrite cryptlib.vcxproj
'vcupgrade.exe' is not recognized as an internal or external command,
operable program or batch file.
Command exited with code 1

我的问题是,我们如何告诉Appveyor更改平台工具集?是否有运行步骤VCUpgrade的步骤或配置选项?还是我们要做其他事情?

My question is, how do we tell Appveyor to change the platform toolset? Is there a step or configuration option to run VCUpgrade? Or do we do something else?

这是在本地运行VCUpgrade时提供的帮助:

This is the help provided when running VCUpgrade locally:

> vcupgrade
Microsoft (R) Visual C++ Project Convert Utility - Version 11.00.61030
Copyright (C) Microsoft Corporation. All rights reserved.

  Usage: VCUpgrade [options] <project file>

  Options:
     -nologo            Suppresses the copyright message
     -nocolor           Do not output error and warning messages in color
     -overwrite         Overwrite existing files
     -PersistFramework  Keep the Target Framework Version while upgrading. (-p)

推荐答案

VCUpgrade可能不存在,具体取决于所使用的工具集.例如我有VS2013,VS2015,但没有VS2017.相应的功能是devenv /upgrade my.vcxproj,尽管至少从VS2013(可能更早)可以使用.您可以在Appveyor中将其作为额外的构建步骤来运行,除非您使用的是devenv不想修改的自定义项目文件布局.

VCUpgrade might not exist depending on the toolset used. For example I have it for VS2013, VS2015 but not for VS2017. The corresponding functionality is devenv /upgrade my.vcxproj though which is available at least from VS2013, possibly earlier. And you can run it as an extra build step in Appveyor, were it not that you use a custom project file layout which devenv doesn't want to touch.

通过将项目文件$(DefaultPlatformToolset)中的V100替换为

Either make your project file compatible with multiple VS versions by replacing V100 in your project file $(DefaultPlatformToolset), as layed out in the other question on this subject, or replace V100 manually. I don't know if appveyor has sed in the path by default but you can do Powershell builds instead and PS has sed-like capabilities. You do need to derive the toolset manually depending on the build worker image used though. Something like this does the trick:

configuration:

- Debug
- Release

platform:

- x86
- x64

image:

- Visual Studio 2017
- Visual Studio 2015
- Visual Studio 2013

build_script:

- ps: >-

    if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2013") {
      $PlatformToolset = "v120"
    } elseif ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2015") {
      $PlatformToolset = "v140"
    } else {
      $PlatformToolset = "v141"
    }

    (Get-Content cryptlib.vcxproj) | %{$_ -replace "v100", $PlatformToolset} | Set-Content cryptlib.vcxproj

    (Get-Content cryptest.vcxproj) | %{$_ -replace "v100", $PlatformToolset} | Set-Content cryptest.vcxproj

    & msbuild cryptlib.vcxproj "/p:platform=$env:platform;configuration=$env:configuration"

    & msbuild cryptest.vcxproj "/p:platform=$env:platform;configuration=$env:configuration"

这篇关于在Appveyor构建之前如何运行VCUpgrade?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆