How to run VCUpgrade before Appveyor build?

放肆的年华 提交于 2019-12-05 01:31:05

AppVeyor currently provides build worker images with VS 2013, 2015 and 2017. There are no plans to add VS 2010 and 2012 at the moment, sorry.

Interesting option for you could be custom build environment. It is "hybrid" solution where you own infrastructure and images, and AppVeyor provides UI and orchestration. Documentation for Azure and Hyper-V is available now, documentation for other providers is on it's way.

Note that custom build environments are available for Premium plan customers now. If you want to try, please mail to team at appveyor.com.

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.

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"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!