When I publish my .Net project in VS only few and required folders are publishing, but while I publish from Azure devops pipiline. I am getting all the git code including csproj, sql files etc. There might be some configuration which I am missing, please let me know where to control the publish task
tried changing the publish path
Manoj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
You can configure your pipeline like as below,
# azure-pipelines.yml
steps:
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: restore
projects: 'path/to/project-name.csproj'
- task: DotNetCoreCLI@2
displayName: 'dotnet publish'
inputs:
command: publish
publishWebProjects: false
projects: 'path/to/project-name.csproj'
arguments: '--no-restore -c $(buildConfiguration) -o $(Build.ArtifactStagingDirectory)'
modifyOutputPath: false
# The subsequent step to publish the ZIP file from the directory '$(Build.ArtifactStagingDirectory)' to the target service.
. . .
-
The ‘
dotnet restore
‘ step will restore the required NuGet packages to build the specified project (.csproj
). -
The ‘
dotnet publish
‘ step will do the following things:- Build the specified project (
.csproj
). - Archive the build artifact files (generated by build) and the resources/dependence files required by the project into a ZIP file.
- The ZIP file will be put to the specified directory “
$(Build.ArtifactStagingDirectory)
“.
- Build the specified project (
-
After the ‘
dotnet restore
‘ step, you can use the related deploy step to deploy the ZIP file to the target service.