4

I am getting an error on deployment to IIS:

2020-04-06T10:51:49.9302914Z ##[error]Error: No package found with specified pattern.<br/>Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.

I had:

$(System.DefaultWorkingDirectory)\**\*.zip

as the package folder in IIS Web App Deploy task and after first I got the error I changed the folder by selecting the folder location:

$(System.DefaultWorkingDirectory)/_MyProject-ASP.NET-CI

but it didn't help anything. The error stays the same.

This is my YAML:

steps:
- task: IISWebAppDeploymentOnMachineGroup@0
  displayName: 'IIS Web App Deploy'
  inputs:
    WebSiteName: '$(Parameters.WebsiteName)'
    VirtualApplication: dev.myproject.com
    Package: '$(System.DefaultWorkingDirectory)/_MyProject-ASP.NET-CI'
    ExcludeFilesFromAppDataFlag: true
    TakeAppOfflineFlag: True
    XmlTransformation: true
    XmlVariableSubstitution: True

and the following for Publish Artifact task:

steps:
- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
    ArtifactName: '$(Parameters.ArtifactName)'
  condition: succeededOrFailed()

I also have a Copy files task in my build:

steps:
- task: CopyFiles@2
  displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
  inputs:
    SourceFolder: '$(Build.SourcesDirectory)'
    TargetFolder: '$(Build.ArtifactStagingDirectory)'

before the Publish Artifact task.

I have looked for similar issue but found only such solutions: Azure DevOps pipeline release Error: No package found with specified pattern: D:\a\r1\a\**\*.zip which are not relevant since my YAML looks like they're advising and I have Copy files task as mentioned already.

Full log for this stage:

2020-04-06T10:51:48.3476113Z ##[section]Starting: IIS Web App Deploy
2020-04-06T10:51:48.3785215Z ==============================================================================
2020-04-06T10:51:48.3786130Z Task         : IIS web app deploy
2020-04-06T10:51:48.3786911Z Description  : Deploy a website or web application using Web Deploy
2020-04-06T10:51:48.3787618Z Version      : 0.156.9
2020-04-06T10:51:48.3788205Z Author       : Microsoft Corporation
2020-04-06T10:51:48.3789263Z Help         : https://learn.microsoft.com/azure/devops/pipelines/tasks/deploy/iis-web-app-deployment-on-machine-group
2020-04-06T10:51:48.3790410Z ==============================================================================
2020-04-06T10:51:49.9302914Z ##[error]Error: No package found with specified pattern.<br/>Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.
2020-04-06T10:51:49.9420801Z ##[section]Finishing: IIS Web App Deploy

I'm running out of ideas what this can be!

I am new to release so I am totally not sure what else can be missing or whether I am setting it up correctly.

EDIT

This is full build YAML:

pool:
  name: Azure Pipelines
  demands:
  - msbuild
  - visualstudio

    steps:
    - task: NuGetToolInstaller@0
      displayName: 'Use NuGet 4.4.1'
      inputs:
        versionSpec: 4.4.1

    - task: NuGetCommand@2
      displayName: 'NuGet restore'
      inputs:
        restoreSolution: '$(Parameters.solution)'

    - task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@3
      displayName: 'Use Yarn 1.22.1'
      inputs:
        versionSpec: 1.22.1

    - task: geeklearningio.gl-vsts-tasks-yarn.yarn-task.Yarn@3
      displayName: 'Yarn install'
      inputs:
        projectDirectory: Web
        arguments: install

    - task: geeklearningio.gl-vsts-tasks-yarn.yarn-task.Yarn@3
      displayName: 'Yarn build'
      inputs:
        projectDirectory: Web
        arguments: build

    - task: VSBuild@1
      displayName: 'Build solution'
      inputs:
        solution: '$(Parameters.solution)'
        msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"'
        platform: '$(BuildPlatform)'
        configuration: '$(BuildConfiguration)'

    - task: VSTest@2
      displayName: 'Test Assemblies'
      inputs:
        testAssemblyVer2: |
         **\$(BuildConfiguration)\*test*.dll
         !**\obj\**
        platform: '$(BuildPlatform)'
        configuration: '$(BuildConfiguration)'
      enabled: false

    - task: PublishSymbols@2
      displayName: 'Publish symbols path'
      inputs:
        SearchPattern: '**\bin\**\*.pdb'
        PublishSymbols: false
      continueOnError: true

    - task: CopyFiles@2
      displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
      inputs:
        SourceFolder: '$(Build.SourcesDirectory)'
        TargetFolder: '$(Build.ArtifactStagingDirectory)'

    - task: PublishBuildArtifacts@1
      displayName: 'Publish Artifact'
      inputs:
        PathtoPublish: '$(build.artifactstagingdirectory)'
        ArtifactName: '$(Parameters.ArtifactName)'
      condition: succeededOrFailed()

EDIT 2

The log of VSBuild task:

2020-04-07T15:37:05.6665411Z ##[section]Starting: Build solution
2020-04-07T15:37:05.7033615Z ==============================================================================
2020-04-07T15:37:05.7034084Z Task         : Visual Studio build
2020-04-07T15:37:05.7034450Z Description  : Build with MSBuild and set the Visual Studio version property
2020-04-07T15:37:05.7034755Z Version      : 1.166.0
2020-04-07T15:37:05.7034990Z Author       : Microsoft Corporation
2020-04-07T15:37:05.7035347Z Help         : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/visual-studio-build
2020-04-07T15:37:05.7036406Z ==============================================================================
2020-04-07T15:37:13.7071155Z ##[command]"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [16.0,17.0) -latest -format json
2020-04-07T15:37:13.7989257Z ##[command]"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [16.0,17.0) -products Microsoft.VisualStudio.Product.BuildTools -latest -format json
2020-04-07T15:37:13.8796977Z ##[command]"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [15.0,16.0) -latest -format json
2020-04-07T15:37:14.2358042Z ##[command]"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" "D:\a\1\s\myproject.com.sln" /nologo /nr:false /dl:CentralLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=0ce4c4e1-c2fb-42a2-b03b-860f664e3238|SolutionDir=D:\a\1\s"*ForwardingLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="D:\a\1\a\\" /p:platform="any cpu" /p:configuration="release" /p:VisualStudioVersion="15.0" /p:_MSDeployUserAgent="VSTS_ec7516ed-027d-4f0f-95e9-525fa5443e34_build_6_0"
2020-04-07T15:37:14.3407720Z Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
2020-04-07T15:37:14.3741342Z Build started 4/7/2020 3:37:14 PM.
2020-04-07T15:37:14.5565930Z ##[warning]D:\a\1\s\myproject.com.sln.metaproj(0,0): Warning MSB4126: The specified solution configuration "release|any cpu" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the default solution configuration.
2020-04-07T15:37:14.5685931Z Project "D:\a\1\s\myproject.com.sln" on node 1 (default targets).
2020-04-07T15:37:14.5693512Z D:\a\1\s\myproject.com.sln.metaproj : warning MSB4126: The specified solution configuration "release|any cpu" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the default solution configuration. [D:\a\1\s\myproject.com.sln]
2020-04-07T15:37:14.5773938Z Done Building Project "D:\a\1\s\myproject.com.sln" (default targets).
2020-04-07T15:37:14.5806168Z 
2020-04-07T15:37:14.5806758Z Build succeeded.
2020-04-07T15:37:14.5931062Z 
2020-04-07T15:37:14.5943625Z "D:\a\1\s\myproject.com.sln" (default target) (1) ->
2020-04-07T15:37:14.5945416Z (ValidateSolutionConfiguration target) -> 
2020-04-07T15:37:14.5948111Z   D:\a\1\s\myproject.com.sln.metaproj : warning MSB4126: The specified solution configuration "release|any cpu" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the default solution configuration. [D:\a\1\s\myproject.com.sln]
2020-04-07T15:37:14.5952737Z 
2020-04-07T15:37:14.5952959Z     1 Warning(s)
2020-04-07T15:37:14.5953123Z     0 Error(s)
2020-04-07T15:37:14.5954912Z 
2020-04-07T15:37:14.5955667Z Time Elapsed 00:00:00.20
2020-04-07T15:37:14.6534792Z ##[section]Finishing: Build solution
nickornotto
  • 1,946
  • 4
  • 36
  • 68
  • Can you put your full YAML file? I wonder in what order you have your tasks. – Krzysztof Madej Apr 06 '20 at 13:22
  • @Krzysztof I already showed *IIS Web App Deploy* `YAML` above. I have pasted the full build's YAML now. Although I am not sure Copy files should be there in the build cos now all builds take very long time – nickornotto Apr 06 '20 at 14:44
  • you copy whole source directory. For me this is a mistake. And you already publish your package to ArtifactStagingDirectory. I would recommend you to remove CopyFiles task and before PublishBuildArtifact add powershell task (put it after task: VSBuild@1 task) to check what is inside ArtifactStagingDirectory. - task: PowerShell@2 inputs: targetType: 'inline' script: ls '$(build.artifactstagingdirectory)' – Krzysztof Madej Apr 06 '20 at 14:58
  • @Krzysztof I have done that, not sure what it is supposed to do? Also if I don't copy files I get `##[warning]Directory 'D:\a\1\a' is empty. Nothing will be added to build artifact 'drop'.` warning on build and this is probably the source of my error too. – nickornotto Apr 06 '20 at 15:40
  • Have you verified that the build is actually being publish correctly? – Calidus Apr 06 '20 at 15:47
  • I did check the website yes and it's not working. Besides the release throws an error and doesn't finish as per my post so how on earth it could have published correctly? @Calidus – nickornotto Apr 06 '20 at 17:02
  • I didn't word that last comment very well, Have you downloaded the build artifact using the dev.azure.com and inspected it? – Calidus Apr 06 '20 at 17:40
  • Yes, and if I have `Copy files` task then the build succeeds and the artifact is getting created. If I remove `Copy files` task as per @Krzysztof suggestion I am getting artifact warning on build @Calidus – nickornotto Apr 07 '20 at 15:55
  • You don't need `Copy files` task because you already publish your artifact to this folder. Please notice last parameter in msbuildargs in `VSBuild` task - it is `/p:PackageLocation="$(build.artifactstagingdirectory)\\"` and your `Copy task` copies whole source code into staging directory. To sum up, do we solve your issue? – Krzysztof Madej Apr 08 '20 at 04:20
  • No, nothing above solves my issue, the error persists and the deployment fails @Krzysztof – nickornotto Apr 08 '20 at 10:50

2 Answers2

3

I'm running out of ideas what this can be!

It seems that you're using Microsoft-hosted agent to run your build and release pipeline. Note: Each time you run a pipeline(job/stage), you get a fresh virtual machine.

So Azure Devops actually provides different VMs to run your build yaml and release yaml, the ArtifactStagingDirectory in build yaml and release yaml is not the same location (They're even not in same machine). Also, $(Build.ArtifactStagingDirectory) is build variables instead of release variables. I believe above points are the reason why your IIS Web App Deploy task complained about the missing artifact package.

Suggestion for this issue:

Build Artifact can be used to share files between build and release pipelines. The correct way to use that is: 1. Use Publish Build Artifact or Publish Pipeline Artifact in Build pipeline to publish artifact. 2. Then use Download Build Artifacts or Download Pipeline Artifacts task in release pipeline to download the published artifact from build pipeline.

You need one extra task to download the artifact from build pipeline to the VM that runs your release pipeline. After that your deploy task can access the missing artifact in release pipeline.

For your scenario: It occurs that your build yaml and release yaml aren't in same multi-stage pipeline, so pipeline artifact is more recommended now for you.

enter image description here

Choose current run if your build and release are in same yaml pipeline, choose specific run(build tags is not necessary option) if you want to use source from another build pipeline. After execution, this task will download and extract the artifact from build in your release agent.

LoLance
  • 25,666
  • 1
  • 39
  • 73
  • What do you mean build and release are in the same yaml pipeline? Do you mean whether my release uses the same build as pull request? I am confused @Lance – nickornotto Apr 07 '20 at 15:55
  • 1
    I mean according to the content you shared above, it seems you used one yaml pipeline to build and another yaml pipeline to deploy. But no matter you use `one to build and deploy` or `one build yaml+one deploy yaml`, the download pipeline artifact task should make some help for your issue. You can try the task... – LoLance Apr 08 '20 at 10:19
0

I simplified a bit your case and I got package in build.artifactstagingdirectory

This is mine YAML file

trigger:
- master

pool:
  vmImage: 'windows-latest'

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'

- task: NuGetToolInstaller@1
  displayName: 'Use NuGet 5.5.1'
  inputs:
    versionSpec: 5.5.1

- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: 'stackoverflow/01/TestApp/TestApp.sln'

- task: VSBuild@1
  inputs:
    solution: 'stackoverflow/01/**/*.sln'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"'
    restoreNugetPackages: true

- script: |
    echo '$(build.artifactstagingdirectory)'
    ls '$(build.artifactstagingdirectory)'
  displayName: 'Run a multi-line script'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
    ArtifactName: 'SO-01'
  condition: succeededOrFailed()

This I have in VSBuil task log

2020-04-07T09:33:49.9422539Z   Successfully executed Web deployment task.
2020-04-07T09:33:49.9523439Z   Package "WebApp.zip" is successfully created as single file at the following location:
2020-04-07T09:33:49.9526188Z   file:///d:/a/1/a

And if I check a directory build.artifactstagingdirectory I have this: enter image description here

Can you try with really simple build pipeline like one above? Please remove all Yarn and other not needed tasks (not needed for purpose of packaging). Here you have link for my solution if you consider this valuable. And can you post log of your VSBuild task?

Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107
  • Now that I removed the `Copy files` task I am again getting the error in the build logs: `2020-04-07T15:37:16.1260382Z ##[warning]Directory 'D:\a\1\a' is empty. Nothing will be added to build artifact 'drop'.` and successively the error message I mentioned above. – nickornotto Apr 07 '20 at 15:45
  • And actually where `D:\a\1\a` is supposed to be located? On the target machine? – nickornotto Apr 07 '20 at 15:47
  • No, `D:\a\1\a' is a directory on build agent. Can you attach log of your `VSBuild@1` task? – Krzysztof Madej Apr 08 '20 at 11:25
  • I have edited my question and added the build log @Krzysztof – nickornotto Apr 08 '20 at 14:16
  • @nickornotto are you sure that you have in your solution a web project? Can you tell what kind of project do you have in your solution? These question may appear to be stupid, but I got similar output for solution without web project. Can you put a screen of your Visual Studio solution explorer? – Krzysztof Madej Apr 08 '20 at 20:43
  • Yes, I've got a web project, even quite extensive, it's umbraco more specifically, not that it is important lol @Krzysztof – nickornotto Apr 08 '20 at 20:50
  • If I follow these steps here https://our.umbraco.com/documentation/getting-started/setup/install/install-umbraco-with-nuget will I get project similar to your? – Krzysztof Madej Apr 08 '20 at 22:15