C1X
C1X

Reputation: 795

Azure Pipeline: Project file(s) matching the specified pattern were not found

this is my pipeline:

pool:
  vmImage: windows-latest

steps:
- task: NuGetToolInstaller@1
  displayName: 'Install NuGet >=6.3.0-0'
  inputs:
    versionSpec: '>=6.3.0-0'
    checkLatest: true
    
- task: UseDotNet@2
  displayName: Use DotNet Version 7.0.x
  inputs:
    version: '7.0.x'
    includePreviewVersions: true # Required for preview versions

- task: NuGetCommand@2
  displayName: 'Nuget Restore Packages'
  inputs:
    command: 'restore'
    restoreSolution: '**/*.sln'
    feedsToUse: 'select'
    vstsFeed: '11b33a23-a7bd-4e05-bce5-7383e054c4f4/3aef100d-2005-4893-9c82-65ed96a2b539'

- task: DotNetCoreCLI@2
  displayName: 'Build Web API projects'
  inputs:
    command: build
    projects: '**/*src/*.csproj'
    arguments: '--configuration $(buildConfiguration)' # Update this to match your need

- task: DotNetCoreCLI@2
  displayName: 'Build Database Migrator'
  inputs:
    command: 'publish'
    publishWebProjects: false
    projects: '**/*tools/*DatabaseMigrator.csproj'
    arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)/App_Data/jobs/triggered -r win-x64 --self-contained false'

- task: DotNetCoreCLI@2
  displayName: 'Build Frequently Operations'
  inputs:
    command: 'publish'
    publishWebProjects: false
    projects: '**/*tools/*FrequentlyOperations.csproj'
    arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)/App_Data/jobs/continuous -r win-x64 --self-contained false'

- task: DotNetCoreCLI@2
  displayName: 'Create Zip Build For Release'
  inputs:
    command: publish
    publishWebProjects: True
    arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
    zipAfterPublish: true

# this code takes all the files in $(Build.ArtifactStagingDirectory) and uploads them as an artifact of your build.
- task: PublishPipelineArtifact@1
  displayName: 'Publish Artifact(Zip File) For Release'
  inputs:
    targetPath: '$(Build.ArtifactStagingDirectory)' 
    artifactName: 'output'

when it is triggered it shows this error:

Starting: Build Web API projects ============================================================================== Task : .NET Core Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command Version : 2.210.0 Author : Microsoft Corporation Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli ============================================================================== C:\Windows\system32\chcp.com 65001 Active code page: 65001 Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version. Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://docs.microsoft.com/en-us/dotnet/core/tools/ and https://docs.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting ##[error]Project file(s) matching the specified pattern were not found. Finishing: Build Web API projects

this is my project:

enter image description here

Any suggestions ?

Upvotes: 0

Views: 11564

Answers (2)

Kevin Lu-MSFT
Kevin Lu-MSFT

Reputation: 35504

##[error]Project file(s) matching the specified pattern were not found.

Reproduce the same issue when the csproj file is not in the root node of the src folder.

For example:

-- src 
  --projectname
   -- xxx.csproj 
  -- projectname1

Usually the src folder will contain multiple project folders.

To solve this issue, you need to check the src folder structure and define the folder path of the dotnet task.

For example:

- task: DotNetCoreCLI@2
  displayName: 'Build Web API projects'
  inputs:
    command: build
    projects: '**/*src/** or subfolder name/*.csproj'
    arguments: '--configuration $(buildConfiguration)'

Upvotes: 0

Jiawei Shi - MSFT
Jiawei Shi - MSFT

Reputation: 224

From the screenshot of your repo, I didn't see a csproj in your project. You need to have a csproj in your project. You could also use sln to restore and build your project.

steps:
- task: UseDotNet@2
  displayName: 'Install .NET Core SDK'
  inputs:
    version: 5.0.x
    performMultiLevelLookup: true
    includePreviewVersions: true # Required for preview versions
- task: DotNetCoreCLI@2
  inputs:
    command: 'restore'
    projects: '**/*.sln'
  displayName: 'Restore Nuget Packages'
 
- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    projects: '**/*.sln'
    arguments: '--no-restore'
  displayName: 'Build projects'

- task: DotNetCoreCLI@2
  inputs:
   command: 'publish'
   publishWebProjects: true
   arguments: '--configuration $(buildConfiguration) --output $(build.ArtifactStagingDirectory)'

- task: PublishBuildArtifacts@1    
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
    ArtifactName: 'api.chibebinam'

Upvotes: 1

Related Questions