Build Fails with "Error:The process '/usr/bin/dotnet' failed with exit code 1" after adding "no-build:true" in the dotnet pack command

10,012

Solution 1

Thanks for the other answers that may be related to the issue but things were already taken care.

The issue was only on the Linux Environment because of an issue in .NET SDK. Refer here

The error(DLLs could not be found in the path specified ) that was being generated was correct in somehow but also it was misleading. The DLLs were being generated in Release folder at the build stage and when I was packing the DLLs they were being searched in release folder. Though Release and release remains the same in Windows Environment but Ubuntu being case sensitive generates the Error.

The SDK implementation of .Net Core missed the IgnoreCase in the Regex option and that caused the build to break on switchin to a Linux Agent.

DotnetBuild: enter image description here

Dotnet Pack: enter image description here

Solution: Define the folder where to generate the DLLs in the .csproj and the automatically build and pack step would pick the DLLs from there.

Solution 2

For this error NU5026 ,it refers to the project being packed has not been built yet and hence cannot be packed. Please view this reference.

The file ''F:\project\bin\Debug\net461\project.exe' to be packed was not found on disk.

According to your description, you canceled the automatic build before pack. There's possibility that your build task and pack task did't run with same configuration. For example, In dotnet build task, the project is automatically built with Debug configuration, and in the pack task you set the configuration as Release.

In dotnet build task, the project is automatically built with Debug configuration.

enter image description here

In the dotnet pack task , the default Configuration to Package is Release

enter image description here

If you do not cancel the automatic build before pack, in the .net pack task the project is built in Release configuration.

enter image description here

So please check the log of your build task and pack task, make sure the dotnet build command and dotnet pack command use the same configuration.

Share:
10,012

Related videos on Youtube

Shubhanshu Rastogi
Author by

Shubhanshu Rastogi

Software Developer at Klingelnberg India Ptd Ltd.

Updated on June 04, 2022

Comments

  • Shubhanshu Rastogi
    Shubhanshu Rastogi over 1 year

    The CI pipeline works well if I remove the nobuild:true option from the DotNetCoreCLI@2 task to pack the Project (ie to create a NuGet package) but I am not able to understand what special except not building the project does the nobuild option brings. I need not want to build the Project again as the Previous task have already build the Project and locked the Assembly version of DLLs generated. I want to use the same build to create the NuGet package and to do the same I need to pass the NoBuild option but doing the same breaks the pipeline.

    The pipeline gives the error that the DLLs to be packed are not present at the specified location but I tried to look at the location and I could find the DLLs.One thing that confuses me is that though I have given nobuild to be true but still the tasks shows as Building the Project.

    - task: DotNetCoreCLI@2
      displayName: ".NET pack"
      inputs:
        command: pack
        packagesToPack: ${{ parameters.packagesToPack }}
        nobuild: true
        versioningScheme: byEnvVar
        versionEnvVar: CI_Version
        packDirectory: $(build.artifactStagingDirectory)\${{ parameters.packTo }}
        verbosityPack: 'Normal'
    

    Error:

    Its also important to note that the same thing( nobuild:true) works on Windows Agent but it fails on Ubuntu Agent.

    PS: It could be a case where windows has upgraded the agent and has caused the issue. I searched over the issue and found that one has to lock the .net SDK in the build pipeline

  • Shubhanshu Rastogi
    Shubhanshu Rastogi almost 4 years
    Thanks for the information but I have built the code in release mode and also packed it in the release mode.The issue is on the Ubuntu machine only and everything works on Windows machine. Though I have figured out the issue and it is an error in .NET SDK
  • Hugh Lin
    Hugh Lin almost 4 years
    Thanks for sharing your solution here, you could accept your solution as the answer? So it would be helpful for other members who get the same issue to find the solution easily. Have a nice day:)
  • Jack Zhai-MSFT
    Jack Zhai-MSFT almost 4 years
    @Shubhanshu Rastogi, It seems that your solution was not accept as the answer:). Thanks for your sharing.
  • user1574598
    user1574598 over 2 years
    Just to add to this, I had the same error after changing the target framework to standard 2.1, but it was nothing to do with the pack itself, it was my tests not being run because I had the wrong path to the csproj so therefore the pack did not have a dll to pack. I never looked at the tests at first because I had a green tick so I assumed they were fine.