问题
Does anybody know if it is possible to use VS2019 with TFS2018 vnext build system. You cannot select VS2019 in the build definition, but you can select "Latest" as version for Visual Studio. Unfortunately, this does not select VS2019.
I have tested this in a virtual machine with VS2017 and VS2019 installed. I also upgraded TFS2018 to Azure DevOps Server 2019, which solved the problem. But this is not a "quick" solution for our production environment.
Here are the logs from my tests. As you can see, selecting "Latest" as version for Visual Studio ended in and error, that no VS was selected at all:
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\1.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\1.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 Latest:
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\1.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\1.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\1.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\1.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 Server 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\1.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\1.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 Server 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\1.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\1.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.
回答1:
It's not an easy fix. The changes required were pretty extensive.
Officially, the built-in tasks are only upgraded when you upgrade the server to it's next Update version or Major version. TFS 2018 update 3.2 is the latest update version for TFS 2018 and given that Azure DevOps Server 2019 (the new name for TFS) has just been released, I expect that no new versions of the tasks will ship for TFS 2018 update 4 should it ever see the light.
Workaround
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.
You can clone the Azure Pipelines Tasks repo, build it locally and then use tfx-cli to upgrade the built-in tasks in your server.
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}}
Repeat for every Project Collection on your server.
来源:https://stackoverflow.com/questions/55586463/using-vs2019-with-tfs2018-vnext-build-system