Azure Devops VSBuild task suddenly fails, by MSBuild auto-detection wrong version of msbuild

Santhosh R 10 Reputation points
2025-04-21T22:02:34.0433333+00:00

Previous working VSBuild task output details.

MSBuild auto-detection: using msbuild version '4.0' from 'C:\Windows\Microsoft.NET\Framework\v4.0.30319'.

Now I'm having issue

MSBuild auto-detection: using msbuild version '17.13.15.12501' from 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\bin'.

Pipeline trigger:

- master

pool:

  vmImage: 'windows-latest'

variables:

  solution: '**/*.sln'

  buildPlatform: 'Any CPU'

  buildConfiguration: 'Release'

steps:

- task: NuGetToolInstaller@1

- task: NuGetCommand@2

  inputs:

    command: 'restore'

    restoreSolution: '**/*.sln'

    feedsToUse: 'select'

    vstsFeed: '****'

- task: VSBuild@1

  inputs:

    solution: '$(solution)'

    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:DeployDefaultTarget=WebPublish /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'

    platform: '$(buildPlatform)'

    clean: true

    configuration: '$(buildConfiguration)'

    restoreNugetPackages: true

Developer technologies | C#
{count} vote

2 answers

Sort by: Most helpful
  1. Benjamin Chapoulie 5 Reputation points
    2025-04-24T12:08:29.6233333+00:00

    Hi,

    We also had the same issue and we solved it yesterday the same way, putting the restoreNugetPackages to false.

    From my understanding (from our pipelines logs), till recently the VSBuild task on Azure agents was using the version 4.0 of MSBuild which was still supporting the Nuget restore (with a nice warning that it is deprecated). Now the VSBuild task run with MSBuild version 17 which doesn't support this Nuget and made our pipeline crash.

    Hope it helps and solve your issue.

    1 person found this answer helpful.
    0 comments No comments

  2. Michael Taylor 60,326 Reputation points
    2025-04-22T14:48:54.85+00:00

    We do not currently provide support for Azure DevOps on this site. For Azure DevOps support you should use their official support channels mentioned over here.

    You didn't specify what the actual error itself is so we have no way of helping you. VSBuild uses Visual Studio to build your project. That means it'll use whatever version of MSBuild VS is configured. FOr VS 2022 that is the v17 version. The v4 version was the last version of MSBuild for NET 4 before switching over to MSBuild integration for newer frameworks.

    It sounds like you changed from using MSBuild to VSBuild which would naturally require a version change. But just switching MSBuild versions wouldn't break things normally. Please provide us the actual build error you're getting.

    If your project builds in VS 2022 then it should work in the pipeline as well. If it doesn't then you might need to continue to use the MSBuild task until it does.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.