I am trying to replicate the following Azure pipeline using the CLI dotnet command:
- task: DotNetCoreCLI@2
inputs:
command: publish
publishWebProjects: True
arguments: '--configuration Release --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: True
So far, I can make the project build, but getting a zip file out of it seems problematic - passing the inputs zipAfterPublish etc appears impossible to pass, although, there is some scattered documentation suggesting these can be passed with -p:"optiona=x;optionb=y" or /p:"optiona=x;optionb=y". I can find no definitive documentation on this.
This is what I have - the build part works, the $PWD/out directory is populated with many files but nothing is zipped:
dotnet publish --configuration Release --output $PWD/out /p:"zipAfterPublish=true;publishWebProjects=true"
I'm guessing this is around how to pass the inputs ( https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops ) correctly to the command.
1.The
zipAfterPublishis one option available only inDotnet Publishtask. If you check the log of dotnet publish task, you'll find it doesn't pass any property likezipAfterPublishto the command:Since only the msbuild property can be passed in this way:
/p:xxx=xxx. ThezipAfterPublishwon't work in command-line as it's not msbuild property, that option is not supported indotnet cli, only available inAzure Devops Dotnet Publish task.2.Normally if we want to publish one .net core web project and zip it after publish using dotnet cli locally, we can use command like:
Or
Which is described in this issue.
Above commands can work in windows to generate a xx.zip folder.
However:
It seems that you're in linux environment, please check this document. If you want to zip the publish folder(generate a package), the
dotnet build/publishwill callmsdeploy.exeto do this job, but since MSDeploy lacks cross-platform support, the following MSDeploy options are supported only on Windows. So dotnet cli command is not supported to generate zip after publish in linux environment... What you want is not supported for now in Linux.Possible workaround:
Since we can use
dotnet publishto publish the project to one folder(Folder works cross-platform), we can call another zip command afterdotnet publishto zip it ourselves.Hope my answer helps to resolve your puzzle :)