Search code examples
c#azure-devopsnuget

DevOps ignore the projects input while dotnet pack


I have very strange behavior in a pipeline in DevOps. First I'll share my pipeline.yml

My azure-pipeline.yml

trigger:
- nuget

variables:
  BuildConfiguration: "Release"
  ProjectFolder: "MediaAssetSquid.Common"

pool:
  vmImage: ubuntu-latest

steps:
- task: DotNetCoreCLI@2
  displayName: "Restore packages"
  inputs:
    command: restore
    projects: "$(ProjectFolder)/**/*.csproj"

- task: DotNetCoreCLI@2
  displayName: "Build with $(BuildConfiguration)"
  inputs:
    command: build
    projects: "$(ProjectFolder)/**/*.csproj"
    arguments: "--configuration $(BuildConfiguration)"

- task: DotNetCoreCLI@2
  displayName: "Pack NuGet packages"
  inputs:
    command: pack
    projects: "$(ProjectFolder)/**/*.csproj"
    nobuild: true
    includesymbols: true
    includesource: true
    versioningScheme: "off"

- task: DotNetCoreCLI@2
  displayName: 'Push NuGet package'
  inputs:
    command: push
    feedsToUse: select
    packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
    nuGetFeedType: internal
    publishVstsFeed: 'RC-Global-NuGet-Feed'
    versioningScheme: off

The restore and build steps run without errors. And now comes what I don't understand. When packaging, DevOps uses a completely different project.

E.g. while restoring the executed command looks like:

/usr/bin/dotnet restore /home/vsts/work/1/s/MediaAssetSquid.Common/MediaAssetSquid.Common.csproj --configfile /home/vsts/work/1/Nuget/tempNuGet_81.config --verbosity Detailed

That is also the expected project path.

And while packaging, DevOps uses the following command:

/usr/bin/dotnet pack /home/vsts/work/1/s/MediaAssetSquid.Audio.Models/MediaAssetSquid.Audio.Models.csproj --output /home/vsts/work/1/a --no-build --include-symbols --include-source /p:Configuration=Release --verbosity Detailed

The project MediaAssetSquid.Audio.Models does exist, but is located completely somewhere else.

To rule out an error, I have already referenced the project path absolutely like this:

- task: DotNetCoreCLI@2
  displayName: "Pack NuGet packages"
  inputs:
    command: pack
    projects: "MediaAssetSquid.Common/MediaAssetSquid.Common.csproj"
    nobuild: true
    includesymbols: true
    includesource: true
    versioningScheme: "off"

And here too, DevOps doesn't use the path MediaAssetSquid.Common/MediaAssetSquid.Common.csproj but rather this one:

MediaAssetSquid.Audio.Models/MediaAssetSquid.Audio.Models.csproj

I have already deleted the pipelines and created new ones. Didn't do anything.

I don't understand why the variable or the absolute project path is not used when packaging.

I have other DevOps projects where everything was okay the way I did it.

Has anyone had a problem like this? Or am I doing something wrong?


Solution

  • In my opinion, this is definitely a bug in DevOps. I clicked on settings in the pack section. Lo and behold, the variable on the right side of the form was missing (see screenshot).

    enter image description here

    After I entered the variable manually into the form field and clicked "Add", it went through immediately. Although nothing changed in the Yaml file.

    enter image description here

    Cost? A working day.