I have an on-prem instance of Azure DevOps 2020.1.1 in the build pipeline I have a build solution task which has visual studio version set to "latest" when building a .NET6 project this fails saying of course .NET6 isn't supported because the latest version it seems to recognize is 2019, 2022 isn't even listed in the visual studio versios drop down.
I have installed visual studio 2022 on the server and the build agents see it (they were updated to the latest agents version).
How do I get the latest visual studio version to show as 2022 in the build solution task? MS hasn't released any updates for the on-prem server for this yet that I know of, is there a way to add it or make it find it?
The trick is to use a MSBUILD task and switch from Version to Specify Location and insert the path to the msbuild.exe of VS2022 e.g. C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\msbuild.exe.
EDIT:
Another way is to use a Command line task and call the executable directly. If you need the complete VS development environment to build your application, than specify the path of the executable in the Tool field for example as "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\devenv.com" and specify the solution and configuration in the Arguments field for example as "MySolution.sln /build "Release|Any CPU".
Look at the screenshot below:

Please make sure your path is correct in the MSBuild.exe task
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With