使用 VS2019 和 TFS2018 vnext 构建系统

Using VS2019 with TFS2018 vnext build system

有谁知道是否可以将 VS2019 与 TFS2018 vnext 构建系统一起使用。 您不能在构建定义中 select VS2019,但可以 select "Latest" 作为 Visual Studio 的版本。 不幸的是,这不是 select VS2019.

我已经在安装了VS2017和VS2019的虚拟机中进行了测试。 我也把TFS2018升级到Azure DevOps Server 2019,问题解决了。 但这不是我们生产环境的 "quick" 解决方案。

这是我的测试日志。如您所见,selecting "Latest" 作为 Visual Studio 的版本结束并出现错误,根本没有 VS selected:

TFS2018/VS2017:

2019-04-05T07:38:58.8044647Z ##[debug]Entering Select-VSVersion.
2019-04-05T07:38:58.8080670Z ##[debug] PreferredVersion: '15.0'
2019-04-05T07:38:58.8363094Z ##[debug]Entering Get-VSPath.
2019-04-05T07:38:58.8393121Z ##[debug] Version: '15.0'
2019-04-05T07:38:58.8464182Z ##[debug]Entering Get-VisualStudio_15_0.
2019-04-05T07:38:58.8516552Z ##[debug]Getting latest Visual Studio 15 setup instance.
2019-04-05T07:38:58.8727275Z ##[debug]Entering Invoke-VstsTool.
2019-04-05T07:38:58.8759258Z ##[debug] FileName: 'C:\b\a1\_w\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda.126.0\ps_modules\MSBuildHelpers\vswhere.exe'
2019-04-05T07:38:58.8790622Z ##[debug] Arguments: '-version [15.0,16.0) -latest -format json'
2019-04-05T07:38:58.8861580Z ##[debug] RequireExitCodeZero: 'True'
2019-04-05T07:38:58.8899897Z ##[command]"C:\b\a1\_w\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda.126.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [15.0,16.0) -latest -format json
2019-04-05T07:38:58.9699602Z ##[debug][
2019-04-05T07:38:58.9775093Z ##[debug]  {
2019-04-05T07:38:58.9805669Z ##[debug]    "instanceId": "716a72e1",
2019-04-05T07:38:58.9836484Z ##[debug]    "installDate": "2018-06-19T06:36:30Z",
2019-04-05T07:38:58.9866720Z ##[debug]    "installationName": "VisualStudio/15.9.11+28307.586",
2019-04-05T07:38:58.9896856Z ##[debug]    "installationPath": "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise",
2019-04-05T07:38:58.9925760Z ##[debug]    "installationVersion": "15.9.28307.586",
2019-04-05T07:38:58.9955813Z ##[debug]    "displayName": "Visual Studio Enterprise 2017",
2019-04-05T07:38:58.9984855Z ##[debug]    "description": "Microsoft DevOps solution for productivity and coordination across teams of any size",
2019-04-05T07:38:59.0016503Z ##[debug]    "updateDate": "2019-04-05T05:41:52.3762392Z",
2019-04-05T07:38:59.0046346Z ##[debug]    "enginePath": "C:\program files (x86)\microsoft visual studio\installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service",
2019-04-05T07:38:59.0076156Z ##[debug]    "channelId": "VisualStudio.15.Release",
2019-04-05T07:38:59.0105757Z ##[debug]    "channelUri": "https://aka.ms/vs/15/release/channel",
2019-04-05T07:38:59.0141128Z ##[debug]    "releaseNotes": "https://go.microsoft.com/fwlink/?LinkId=660692#15.9.11",
2019-04-05T07:38:59.0174229Z ##[debug]    "thirdPartyNotices": "https://go.microsoft.com/fwlink/?LinkId=660708"
2019-04-05T07:38:59.0212954Z ##[debug]  }
2019-04-05T07:38:59.0246814Z ##[debug]]
2019-04-05T07:38:59.0278717Z ##[debug]Exit code: 0
2019-04-05T07:38:59.0330925Z ##[debug]Leaving Invoke-VstsTool.
2019-04-05T07:38:59.0514424Z ##[debug]Leaving Get-VisualStudio_15_0.
2019-04-05T07:38:59.0572938Z ##[debug]Leaving Get-VSPath.
2019-04-05T07:38:59.0606126Z ##[debug]Leaving Select-VSVersion.

TFS2018 / VS 最新:

2019-04-09T05:41:00.8981538Z ##[debug]Entering Select-VSVersion.
2019-04-09T05:41:00.9013462Z ##[debug] PreferredVersion: 'latest'
2019-04-09T05:41:00.9716480Z ##[debug]Entering Get-VSPath.
2019-04-09T05:41:00.9752054Z ##[debug] Version: '15.0'
2019-04-09T05:41:00.9837070Z ##[debug]Entering Get-VisualStudio_15_0.
2019-04-09T05:41:00.9894721Z ##[debug]Getting latest Visual Studio 15 setup instance.
2019-04-09T05:41:01.0055503Z ##[debug]Entering Invoke-VstsTool.
2019-04-09T05:41:01.0093274Z ##[debug] FileName: 'C:\b\a1\_w\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda.126.0\ps_modules\MSBuildHelpers\vswhere.exe'
2019-04-09T05:41:01.0130764Z ##[debug] Arguments: '-version [15.0,16.0) -latest -format json'
2019-04-09T05:41:01.0223884Z ##[debug] RequireExitCodeZero: 'True'
2019-04-09T05:41:01.0351851Z ##[command]"C:\b\a1\_w\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda.126.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [15.0,16.0) -latest -format json
2019-04-09T05:41:01.1433479Z ##[debug][]
2019-04-09T05:41:01.1662464Z ##[debug]Exit code: 0
2019-04-09T05:41:01.1723129Z ##[debug]Leaving Invoke-VstsTool.
2019-04-09T05:41:01.1837285Z ##[debug]Getting latest BuildTools 15 setup instance.
2019-04-09T05:41:01.1876304Z ##[debug]Entering Invoke-VstsTool.
2019-04-09T05:41:01.1908643Z ##[debug] FileName: 'C:\b\a1\_w\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda.126.0\ps_modules\MSBuildHelpers\vswhere.exe'
2019-04-09T05:41:01.1940815Z ##[debug] Arguments: '-version [15.0,16.0) -products Microsoft.VisualStudio.Product.BuildTools -latest -format json'
2019-04-09T05:41:01.1976900Z ##[debug] RequireExitCodeZero: 'True'
2019-04-09T05:41:01.1995329Z ##[command]"C:\b\a1\_w\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda.126.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [15.0,16.0) -products Microsoft.VisualStudio.Product.BuildTools -latest -format json
2019-04-09T05:41:01.2651914Z ##[debug][]
2019-04-09T05:41:01.2684020Z ##[debug]Exit code: 0
2019-04-09T05:41:01.2722901Z ##[debug]Leaving Invoke-VstsTool.
2019-04-09T05:41:01.2761049Z ##[debug]Leaving Get-VisualStudio_15_0.
2019-04-09T05:41:01.2878667Z ##[debug]Leaving Get-VSPath.
2019-04-09T05:41:01.2918773Z ##[debug]Entering Get-VSPath.
2019-04-09T05:41:01.2951134Z ##[debug] Version: '14.0'
2019-04-09T05:41:01.3025150Z ##[debug]Leaving Get-VSPath.
2019-04-09T05:41:01.3060830Z ##[debug]Entering Get-VSPath.
2019-04-09T05:41:01.3091486Z ##[debug] Version: '12.0'
2019-04-09T05:41:01.3161729Z ##[debug]Leaving Get-VSPath.
2019-04-09T05:41:01.3203687Z ##[debug]Entering Get-VSPath.
2019-04-09T05:41:01.3241272Z ##[debug] Version: '11.0'
2019-04-09T05:41:01.3668002Z ##[debug]Leaving Get-VSPath.
2019-04-09T05:41:01.3705810Z ##[debug]Entering Get-VSPath.
2019-04-09T05:41:01.3735775Z ##[debug] Version: '10.0'
2019-04-09T05:41:01.4070765Z ##[debug]Leaving Get-VSPath.
2019-04-09T05:41:01.4578925Z ##[warning]Visual Studio was not found. Try installing a supported version of Visual Studio. See the task definition for a list of supported versions.
2019-04-09T05:41:01.4594500Z ##[debug]Processed: ##vso[task.logissue type=warning]Visual Studio was not found. Try installing a supported version of Visual Studio. See the task definition for a list of supported versions.
2019-04-09T05:41:01.4595403Z ##[debug]Leaving Select-VSVersion.

Azure DevOps 服务器 2019/VS2017:

2019-04-08T08:51:31.5394326Z ##[debug]Entering Select-VSVersion.
2019-04-08T08:51:31.5427853Z ##[debug] PreferredVersion: '15.0'
2019-04-08T08:51:31.8561977Z ##[debug]Entering Get-VSPath.
2019-04-08T08:51:31.8599268Z ##[debug] Version: '15.0'
2019-04-08T08:51:31.8719549Z ##[debug]Entering Get-VisualStudio.
2019-04-08T08:51:31.8759349Z ##[debug] MajorVersion: '15'
2019-04-08T08:51:31.8817839Z ##[debug]Getting latest Visual Studio 15 setup instance.
2019-04-08T08:51:31.9024842Z ##[debug]Entering Invoke-VstsTool.
2019-04-08T08:51:31.9064288Z ##[debug] FileName: 'C:\b\a1\_w\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda.146.0\ps_modules\MSBuildHelpers\vswhere.exe'
2019-04-08T08:51:31.9098181Z ##[debug] Arguments: '-version [15.0,16.0) -latest -format json'
2019-04-08T08:51:31.9176808Z ##[debug] RequireExitCodeZero: 'True'
2019-04-08T08:51:31.9284024Z ##[command]"C:\b\a1\_w\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda.146.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [15.0,16.0) -latest -format json
2019-04-08T08:51:32.3297138Z ##[debug][
2019-04-08T08:51:32.3374619Z ##[debug]  {
2019-04-08T08:51:32.3405784Z ##[debug]    "instanceId": "716a72e1",
2019-04-08T08:51:32.3443076Z ##[debug]    "installDate": "2018-06-19T06:36:30Z",
2019-04-08T08:51:32.3475952Z ##[debug]    "installationName": "VisualStudio/15.9.11+28307.586",
2019-04-08T08:51:32.3508932Z ##[debug]    "installationPath": "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise",
2019-04-08T08:51:32.3543169Z ##[debug]    "installationVersion": "15.9.28307.586",
2019-04-08T08:51:32.3574381Z ##[debug]    "displayName": "Visual Studio Enterprise 2017",
2019-04-08T08:51:32.3605500Z ##[debug]    "description": "Microsoft DevOps solution for productivity and coordination across teams of any size",
2019-04-08T08:51:32.3635154Z ##[debug]    "updateDate": "2019-04-05T05:41:52.3762392Z",
2019-04-08T08:51:32.3665443Z ##[debug]    "enginePath": "C:\program files (x86)\microsoft visual studio\installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service",
2019-04-08T08:51:32.3694997Z ##[debug]    "channelId": "VisualStudio.15.Release",
2019-04-08T08:51:32.3723832Z ##[debug]    "channelUri": "https://aka.ms/vs/15/release/channel",
2019-04-08T08:51:32.3757656Z ##[debug]    "releaseNotes": "https://go.microsoft.com/fwlink/?LinkId=660692#15.9.11",
2019-04-08T08:51:32.3787461Z ##[debug]    "thirdPartyNotices": "https://go.microsoft.com/fwlink/?LinkId=660708"
2019-04-08T08:51:32.3816345Z ##[debug]  }
2019-04-08T08:51:32.3851914Z ##[debug]]
2019-04-08T08:51:32.3883080Z ##[debug]Exit code: 0
2019-04-08T08:51:32.3940945Z ##[debug]Leaving Invoke-VstsTool.
2019-04-08T08:51:32.4207172Z ##[debug]Leaving Get-VisualStudio.
2019-04-08T08:51:32.4269153Z ##[debug]Leaving Get-VSPath.
2019-04-08T08:51:32.4306347Z ##[debug]Leaving Select-VSVersion.

Azure DevOps 服务器 2019/VS2019:

2019-04-08T13:11:16.3262140Z ##[debug]Entering Select-VSVersion.
2019-04-08T13:11:16.3316185Z ##[debug] PreferredVersion: '16.0'
2019-04-08T13:11:16.5683152Z ##[debug]Entering Get-VSPath.
2019-04-08T13:11:16.5713957Z ##[debug] Version: '16.0'
2019-04-08T13:11:16.5830477Z ##[debug]Entering Get-VisualStudio.
2019-04-08T13:11:16.5867812Z ##[debug] MajorVersion: '16'
2019-04-08T13:11:16.5936312Z ##[debug]Getting latest Visual Studio 16 setup instance.
2019-04-08T13:11:16.6207158Z ##[debug]Entering Invoke-VstsTool.
2019-04-08T13:11:16.6236159Z ##[debug] FileName: 'C:\b\a1\_w\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda.146.0\ps_modules\MSBuildHelpers\vswhere.exe'
2019-04-08T13:11:16.6264679Z ##[debug] Arguments: '-version [16.0,17.0) -latest -format json'
2019-04-08T13:11:16.6346113Z ##[debug] RequireExitCodeZero: 'True'
2019-04-08T13:11:16.6390903Z ##[command]"C:\b\a1\_w\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda.146.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [16.0,17.0) -latest -format json
2019-04-08T13:11:16.9463375Z ##[debug][
2019-04-08T13:11:16.9549197Z ##[debug]  {
2019-04-08T13:11:16.9586965Z ##[debug]    "instanceId": "1e8be92e",
2019-04-08T13:11:16.9633525Z ##[debug]    "installDate": "2019-04-05T04:43:03Z",
2019-04-08T13:11:16.9673957Z ##[debug]    "installationName": "VisualStudio/16.0.0+28729.10",
2019-04-08T13:11:16.9708765Z ##[debug]    "installationPath": "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise",
2019-04-08T13:11:16.9740525Z ##[debug]    "installationVersion": "16.0.28729.10",
2019-04-08T13:11:16.9771033Z ##[debug]    "displayName": "Visual Studio Enterprise 2019",
2019-04-08T13:11:16.9806117Z ##[debug]    "description": "Microsoft DevOps solution for productivity and coordination across teams of any size",
2019-04-08T13:11:16.9847474Z ##[debug]    "updateDate": "2019-04-05T04:43:03.9231866Z",
2019-04-08T13:11:16.9890390Z ##[debug]    "enginePath": "C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service",
2019-04-08T13:11:16.9930603Z ##[debug]    "layoutPath": "E:\",
2019-04-08T13:11:16.9974686Z ##[debug]    "channelId": "VisualStudio.16.Release",
2019-04-08T13:11:17.0007956Z ##[debug]    "channelUri": "https://aka.ms/vs/16/release/channel",
2019-04-08T13:11:17.0046086Z ##[debug]    "installChannelUri": "E:\ChannelManifest.json",
2019-04-08T13:11:17.0084654Z ##[debug]    "releaseNotes": "https://go.microsoft.com/fwlink/?LinkId=660893#16.0.0",
2019-04-08T13:11:17.0129982Z ##[debug]    "thirdPartyNotices": "https://go.microsoft.com/fwlink/?LinkId=660909"
2019-04-08T13:11:17.0171988Z ##[debug]  }
2019-04-08T13:11:17.0211123Z ##[debug]]
2019-04-08T13:11:17.0251034Z ##[debug]Exit code: 0
2019-04-08T13:11:17.0310329Z ##[debug]Leaving Invoke-VstsTool.
2019-04-08T13:11:17.0610458Z ##[debug]Leaving Get-VisualStudio.
2019-04-08T13:11:17.0675928Z ##[debug]Leaving Get-VSPath.
2019-04-08T13:11:17.0715177Z ##[debug]Leaving Select-VSVersion.

这不是一个容易解决的问题。 changes required were pretty extensive.

正式来说,内置任务只有在您将服务器升级到下一个更新版本或主要版本时才会升级。 TFS 2018 更新 3.2 是 TFS 2018 的最新更新版本,鉴于 Azure DevOps Server 2019(TFS 的新名称)刚刚发布,我预计 TFS 2018 更新 4 不会发布任何新版本的任务见光。

解决方法

CAUTION this may cause issues when upgrading to another server version at a later stage, may require newer versions of the Azure Pipelines Agent and can put you in an unsupported state.

您可以克隆 Azure Pipelines Tasks repo, build it locally and then use tfx-cli 来升级服务器中的内置任务。

git clone https://github.com/Microsoft/azure-pipelines-tasks.git
cd azure-pipelines-tasks
npm install
npm run-script build --task MSBuildV1
npm run-script build --task VstestV2
npm run-script build --task VSBuildV1

npm install tfx-cli@latest -g
tfx build tasks upload --task-path .\MSBuildV2 --service-url {{https://server/tfs/collection}}
tfx build tasks upload --task-path .\VsTestV2 --service-url {{https://server/tfs/collection}}
tfx build tasks upload --task-path .\VsBuildV1 --service-url {{https://server/tfs/collection}}

对服务器上的每个项目集合重复此操作。