Search code examples
azureazure-devopsazure-web-app-serviceazure-pipelinesazure-pipelines-release-pipeline

Error: Deployment of msBuild generated package is not supported. Change package format or use Azure App Service Deploy task


Continue to my previous Question-Answer,

I tried changing the Agent Specification to windows-latest and also step/task in the release pipeline from Deploy Azure App service to Azure Web App Deploy:

enter image description here

Received this error:

##[error]Error: Deployment of msBuild generated package is not supported. 
Change package format or use Azure App Service Deploy task. 
D:\a\r1\a\_DotNet8WebApp\drop\WebApp.zip

Solution

  • Refer to this doc: Error: Publish using zip deploy option is not supported for msBuild package type

    Web packages created via the MSBuild task (with default arguments) have a nested folder structure that can be deployed correctly only by Web Deploy. The publish-to-zip deployment option can't be used to deploy those packages.

    When we use the Azure Web App deploy task, it only have Zip deploy and Run From Package option. And Deploy Azure App service task contains the Web Deploy option.

    For example: Azure Web App deploy task

    enter image description here

    In this case, it will show the error in your pipeline.

    If your WebApp package is created by Visual Studio build task or Msbuild task, you need to modify the pipeline with the following steps:

    1.In the Build solution task, change the MSBuild Arguments to /p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl="$(System.DefaultWorkingDirectory)\\WebAppContent":

    enter image description here

    2.Add an Archive task and change the values as follows:

    a. Change Root folder or file to archive to $(System.DefaultWorkingDirectory)\\WebAppContent.

    b. Clear the Prepend root folder name to archive paths check box:

    enter image description here

    Then the msbuild output files will be zipped by archive files task and it can be used to Azure Web App deploy task.