Visual studio 如何在Appveyor构建之前运行VCUpgrade?

Visual studio 如何在Appveyor构建之前运行VCUpgrade?,visual-studio,appveyor,Visual Studio,Appveyor,我们分发了一组VisualStudio2010项目文件。用户需要升级以适应他们的口味。我们的产品包括以下图像(除配置和平台外): Visual Studio 2017 Visual Studio 2015 Visual Studio 2013 Visual Studio 2012 VisualStudio2010 Visual Studio 2017生成失败,原因是: Build started git clone -q --depth=3 --branch=master https://g

我们分发了一组VisualStudio2010项目文件。用户需要升级以适应他们的口味。我们的产品包括以下图像(除配置和平台外):

  • Visual Studio 2017
  • Visual Studio 2015
  • Visual Studio 2013
  • Visual Studio 2012
  • VisualStudio2010
Visual Studio 2017生成失败,原因是:

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的生成工具(平台工具集='v100')。要使用v100生成工具生成,请安装Visual Studio 2010生成工具。或者,您可以通过选择“项目”菜单或右键单击解决方案,然后选择“重定目标解决方案”,升级到当前的Visual Studio工具

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

当我尝试通过AppVeyor
测试脚本运行它时:
,它会导致另一个失败。例如,从:

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


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

> 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
微软(R)Visual C++项目转换实用程序-版本1100.61030
版权所有(C)微软公司。版权所有。
用法:VCUpgrade[选项]
选项:
-nologo会抑制版权信息
-nocolor不以彩色输出错误和警告消息
-覆盖现有文件
-PersistFramework在升级时保留目标框架版本。(-p)

AppVeyor目前提供。目前没有计划添加VS 2010和2012,抱歉

对您来说,一个有趣的选项是定制构建环境。这是一个“混合”解决方案,您拥有基础架构和映像,AppVeyor提供UI和编排。和的文档现在可用,其他提供商的文档正在提供中


请注意,特优计划客户现在可以使用自定义构建环境。如果您想尝试,请发送邮件至appveyor.com上的团队。

VCUpgrade可能不存在,具体取决于使用的工具集。例如,我有VS2013、VS2015的版本,但没有VS2017的版本。相应的功能是
devenv/upgrade my.vcxproj
,但它至少可以从VS2013(可能更早)获得。如果不是因为使用了devenv不想接触的自定义项目文件布局,您可以在Appveyor中将其作为额外的构建步骤运行

通过替换项目文件$(DefaultPlatformToolset)中的V100使项目文件与多个VS版本兼容,如本主题的另一个问题所述,或者手动替换V100。我不知道appveyor在默认情况下是否在路径中使用了sed,但您可以改为使用Powershell构建,并且PS具有类似sed的功能。您确实需要根据所使用的构建辅助映像手动派生工具集。像这样的东西会起作用:

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或devenv/upgrade等预构建步骤吗?或者,不要将PlatformToolset设置为一个固定的数字并不断修改它,而是将其设置为$(DefaultPlatformToolset),工具集将根据打开项目的VS/environment版本自动更正。谢谢@ilyaf。我们可以删除VS2010和VS2012。我们如何运行
VCUpgrade
sed
?谢谢@stinj。“[VCUpgrade]在较新版本中不存在…”-似乎Microsoft认为VCUpgrade是未来的工具:。它也可以在VS2010-VS2013的“我的开发者”提示中找到。我希望微软能发布一些像样的文档,而不是强迫人们阅读那些博客。我鄙视它们,也不知道它们何时会过时(q.v.)。或者通过替换项目文件$(DefaultPlatformToolset)中的V100使项目文件与多个VS版本兼容。。。“-是的,问题是,
DefaultPlatformToolset
没有文档记录。您在MSDN或博客上也找不到任何关于
DefaultPlatformToolset
的信息。老兄,我希望微软能发布一些像样的文档。事实上,vcupgrade仍然在VS2013甚至VS2015中,我会把它编辑掉。是的,复制更容易,但你只是复制了数百行。即使是自动的,它们仍然是登记的。实际上,你所做的是不正确的,请仔细阅读我的回答:$(DefaultPlatformToolset)必须在Microsoft.Cpp.Default.props之后,否则它没有定义。
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"