How do I stop dotnet pack building the project in azure devops (--no-build doesnt have an effect)

Viewed 1030

I am having issues creating a nuget package from a project in azure devops, The project is .net standard 2.0 targeting netstandard2.0 and netcoreapp2.0.

I have a separate build and release pipelines.

The build pipeline builds & tests the project.

The release pipeline takes the output from the build and runs dotnet pack on it. However it is trying to do a build at the same time (which fails).

The documentation that I have seen suggests that adding --no-build when calling nuget pack should make it use the existing dlls from the bin directory.

I have been through the logs and this is the command that devops has been running (I have removed some identifying information) : pack E:\Agents\build1\r82\a\...\MyProject.csproj --output E:\Agents\build1\r82\a\...\packages --no-build /p:Configuration=Release --verbosity Detailed

This does a build which then fails with a message that some referenced nuget packages could not be found.

I could just put a dotnet restore in there and let it do the build but I don't see why we would need to do that given that the build pipeline has already created the dlls.

Note, I have already seen this but in that instance the issue was that the build was output to a non-standard directory, that is not the case here.

Any help appreciated.

1 Answers

It seems the argument --no-build is not working in dotnet pack of DotNetCoreCLI@2 task. Please try to use dotnet custom as a workaround:

steps:
- task: DotNetCoreCLI@2
  displayName: 'dotnet custom'
  inputs:
    command: custom
    projects: '**\*.csproj'
    custom: pack
    arguments: '--no-build'
Related