Azure DevOps发布至Azure VM失败:IIS部署找不到指定包
Hey Krishna, let's work through fixing that "No package found with specified pattern" error you're hitting when deploying to your Azure VM's IIS. Since you're new to Azure DevOps, I'll walk you through the most common root causes and checks step by step:
First things first—if your build pipeline isn't outputting a deployable ZIP package, the deployment step will never find it.
- Check your build YAML for tasks like
VSBuild@1(for ASP.NET Framework) orDotNetCoreCLI@2(for ASP.NET Core). For example, an ASP.NET Core build needs thepublishcommand to generate a package:- task: DotNetCoreCLI@2 inputs: command: 'publish' publishWebProjects: true arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)' zipAfterPublish: true - Look at your build logs for lines confirming the package was created. You should see something like:
Successfully created package 'D:\a\1\a\YourProject.zip'. If you don't see this, your build isn't configured to generate the package at all.
The error almost always comes from a mismatch between where your build stores the package and where your deployment task is searching for it.
- Check the
packageparameter in yourIISWebAppDeploymentOnMachineGroup@0task (or the IIS deploy task you're using). Common mistakes here:- If you're using a separate build and release pipeline: Your deployment should pull the package from the pipeline workspace, e.g.,
$(Pipeline.Workspace)/drop/**/*.zip(wheredropis the name of your published artifact). - If it's a single build-deploy pipeline: Use
$(Build.ArtifactStagingDirectory)/**/*.zipto reference the package directly from the build's output directory.
- If you're using a separate build and release pipeline: Your deployment should pull the package from the pipeline workspace, e.g.,
- Cross-reference the path in your deployment task with the package path from your build logs. If they don't align, adjust the
packagevalue to match.
If you split your workflow into separate build and release stages:
- Ensure your release pipeline is linked to the correct build artifact. Go to your release pipeline's Artifacts tab and verify you've added the build artifact from your project.
- Check that your build pipeline includes a task to publish the artifact (like
PublishBuildArtifacts@1orPublishPipelineArtifact@1). For example:- task: PublishBuildArtifacts@1 inputs: PathtoPublish: '$(Build.ArtifactStagingDirectory)' ArtifactName: 'drop' publishLocation: 'Container'
This step makes the package available to subsequent deployment stages.
If you're still stuck, add a quick command task right before your IIS deploy step to list all files in your workspace. This will show you exactly what's available to the deployment task:
- task: CmdLine@2 inputs: script: 'dir $(Pipeline.Workspace) /s /b'
Run the pipeline again and check the logs for this task. If you don't see your ZIP package in the output, you'll know the issue is with how the package is being passed (or not passed) to the deployment stage.
Most of the time, this error boils down to a simple path mismatch or a missing step to publish the build artifact. Walk through these checks, and you should be able to get your deployment working.
内容的提问来源于stack exchange,提问作者Krishna Rpr




