.net-coreazure-devopsasp.net-core-cli

Disable package type on nuget


Using dotnetcore cli the packages are being generated with a packagetype node, causing Visual Studio to not be able to install the package. Building the package on Visual Studio does not generate the node, but on dotnetcore cli it gets generated in CI like this:

 <packageTypes>
      <packageType name="api" />
    </packageTypes>

CI steps:

- task: DotNetCoreCLI@2
  displayName: "${{ parameters.name }} - Restore"
  inputs:
    command: 'restore'
    projects: '${{ parameters.projects }}'
    feedsToUse: 'config'
    nugetConfigPath: '$(Build.SourcesDirectory)/NuGet.Config'

- task: DotNetCoreCLI@2
  displayName: "${{ parameters.name }} - Build"
  inputs:
    command: 'build'
    projects: '${{ parameters.projects }}'
    arguments: "--configuration Release --no-cache"

- task: DotNetCoreCLI@2
  displayName: "${{ parameters.name }} - Pack" 
  inputs:
    command: 'pack'
    nobuild: true
    packagesToPack: $(ProjectsToPack)
    versioningScheme: 'byEnvVar'
    versionEnvVar: 'NugetVersion'
    arguments: '--no-dependencies --force --no-cache'

- task: DotNetCoreCLI@2
  displayName: "${{ parameters.name }} - Push"
  inputs:
    command: custom
    custom: nuget
    arguments: >
      push "$(Build.ArtifactStagingDirectory)\*.nupkg"
      -s "$(NugetFeed)"
      -k "$(NugetToken)"

How can i disable it?


Solution

  • It turns out "PackageType" became similar to a reserved word when using DotNetCli, changed the variable name to "ApplicationType" to avoid having the package type in the nuscpec.

      Write-Output ("##vso[task.setvariable variable=PackageType;]$packageType")