Forum Discussion
sanjeevshrestha
Jan 12, 2023Copper Contributor
DotNetCoreCLI@2 (dotnet publish) doesn't publish webapi project
I have a solution with .net core mvc and webapi projects. While publishing this project in build pipeline in azure-devops it publishes mvc code in zip folder but it doesn't publish webapi project code.
here is my publish task:
variables:
buildConfiguration: 'Release'
solution: '**/*.sln'
artifactName: 'drop'
jobs:
- job: Build
steps:
- task: DotNetCoreCLI@2
displayName: Restore
inputs:
command: restore
projects: $(solution)
- task: DotNetCoreCLI@2
displayName: 'Dotnet Build'
inputs:
projects: $(solution)
command: 'build'
arguments: '--configuration $(buildConfiguration)'
# Publish projects to specified folder.
- task: DotNetCoreCLI@2
displayName: 'Dotnet Publish'
inputs:
command: 'publish'
publishWebProjects: true
projects: $(solution)
arguments: '-o $(Build.ArtifactStagingDirectory)'
The webapi project doesn't have web.config or wwwroot but does use Microsoft.NET.Sdk.Web and based on the https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/dotnet-core-cli-v2?view=azure-pipelines#:~:text=In%20the%20absence%20of%20a%20web.config%20file%20or%20a%20wwwroot%20folder%2C%20projects%20that%20use%20a%20web%20SDK%2C%20like%20Microsoft.NET.Sdk.Web%2C%20are%20selected., it should be able to identify that as web project.
Any idea why webapi project is not getting published?
Sanjeev
No RepliesBe the first to reply