Search code examples
azure-devopsazure-pipelinesazure-deployment

Azure Pipeline Archive fails no such file or directory


I am using Azure CI/CD Pipeline. The project is a ASP.NET app (Website project) which builds successfully. The Azure Pipeline Archive fails finding the dir D:/a/_temp/WebAppContent.

I dont know if the "Build Solution" before the "Archive Files" in the pipeline is causing the issue.

Where can I check to make sure the rootFolderOrFile is created before the "Archive Files"?

YAML

steps:
- task: VSBuild@1
  displayName: 'Build solution **\*.sln'
  inputs:
    solution: '$(Parameters.solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:publishUrl="$(Agent.TempDirectory)\WebAppContent\\"'
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'

steps:
- task: ArchiveFiles@2
  displayName: 'Archive Files'
  inputs:
    rootFolderOrFile: '$(Agent.TempDirectory)\WebAppContent'
    includeRootFolder: false

ERROR

ls: no such file or directory: D:/a/_temp/WebAppContent
Found 0 files
##[error]Error: ENOENT: no such file or directory, stat 'D:\a\_temp\WebAppContent'
##[error]ENOENT: no such file or directory, stat 'D:\a\_temp\WebAppContent'
Finishing: Archive Files

Here is my Pipeline screeshot

enter image description here


Solution

  • I solved the issue finally. See the Pipeline I am using below.

    1. Create a new VS Solution and a new Class Library Project

    2. Git Commit  to Azure > and Build (success)

    3. In new solution > Add Existing Project > Website (this is legacy asp.net app with aspx and aspx.cs pages)

    4. In Website, you must add website.publishproj

    5. Build locally and Run locally (success)

    6. Git Commit again to Azure > some DLL missing

    7. Added missing DLL to project using include files

    8. Git Commit again to Azure > now DLL are pushed to Git

    9. Successful Build in Azure.

    The the main issue was I need to create a brand new Solution + Project, then add Existing Website

    enter image description here

    Update: I had to delete the default Archive step and re-add from the Find menu

    enter image description here

    Update 2: Here is the YAML that is working

    trigger:
    - main
    
    pool:
      vmImage: 'windows-latest'
    
    variables:
      solution: '**/*.sln'
      buildPlatform: 'Any CPU'
      buildConfiguration: 'Release'
    
    steps:
    - task: NuGetToolInstaller@1
      displayName: NuGet - Installer
    
    - task: NuGetCommand@2
      displayName: NuGet - Restore
      inputs:
        restoreSolution: '$(solution)'
    
    - task: VSBuild@1
      displayName: VS Build Legacy App publishproj 
      inputs:
        solution: '**\*.publishproj'
        msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
        platform: '$(buildPlatform)'
        configuration: '$(buildConfiguration)'
    
    
    - task: AzureRmWebAppDeployment@4
      displayName: Azure WebApp Publish
      inputs:
        ConnectionType: 'AzureRM'
        azureSubscription: 'Azure WebApp'
        appType: 'webApp'
        WebAppName: 'XXXXXXXX'
        packageForLinux: '$(build.artifactStagingDirectory)/**/*.zip'