Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet pack "Path to csproj or nuspec file(s) to pack" doesn't work as expected #13674

Closed
nandun5 opened this issue Oct 7, 2020 · 8 comments
Closed
Assignees

Comments

@nandun5
Copy link

nandun5 commented Oct 7, 2020

Required Information

Question, Bug, or Feature?
Type: Bug

Enter Task Name: DotNetCoreCLI@2
dotnet pack command

Environment

  • Server - Azure Pipelines

  • Agent - Hosted
    HostedVS2017

Issue Description

The task fails when we specify a nuspec file in the "Path to csproj or nuspec file(s) to pack" field. this is the Yaml version what the UI generates:

steps:
- task: DotNetCoreCLI@2
  displayName: 'dotnet pack'
  inputs:
    command: pack
    packagesToPack: '**/*.nuspec'
    nobuild: true
    versioningScheme: byBuildNumber
  enabled: false

Errorlogs

"C:\Program Files\dotnet\dotnet.exe" pack D:\a\1\s\BBI.PoseidonEnterprise.DataAccess.Orders\BBI.PoseidonEnterprise.DataAccess.Orders.nuspec --output D:\a\1\a /p:Configuration=release /p:PackageVersion=1.0.0.2 --verbosity Detailed
Microsoft (R) Build Engine version 16.7.0+7fb82e5b2 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 10/7/2020 3:49:15 PM.
     0>Process = "C:\Program Files\dotnet\dotnet.exe"
       MSBuild executable path = "C:\Program Files\dotnet\sdk\3.1.402\MSBuild.dll"
       Command line arguments = ""C:\Program Files\dotnet\sdk\3.1.402\MSBuild.dll" -maxcpucount -verbosity:m -restore -target:pack -property:PackageOutputPath=D:\a\1\a -verbosity:Detailed D:\a\1\s\BBI.PoseidonEnterprise.DataAccess.Orders\BBI.PoseidonEnterprise.DataAccess.Orders.nuspec /p:Configuration=release /p:PackageVersion=1.0.0.2 "-distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\Program Files\dotnet\sdk\3.1.402\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\Program Files\dotnet\sdk\3.1.402\dotnet.dll""
       Current directory = "D:\a\1\s\BBI.PoseidonEnterprise.DataAccess.Orders"
       MSBuild version = "16.7.0+7fb82e5b2"
     1>Project "D:\a\1\s\BBI.PoseidonEnterprise.DataAccess.Orders\BBI.PoseidonEnterprise.DataAccess.Orders.nuspec" on node 1 (Restore target(s)).
     1>Building with tools version "Current".
     1>D:\a\1\s\BBI.PoseidonEnterprise.DataAccess.Orders\BBI.PoseidonEnterprise.DataAccess.Orders.nuspec(2,1): error MSB4068: The element <package> is unrecognized, or not supported in this context.
     1>Done Building Project "D:\a\1\s\BBI.PoseidonEnterprise.DataAccess.Orders\BBI.PoseidonEnterprise.DataAccess.Orders.nuspec" (Restore target(s)) -- FAILED.

Build FAILED.

       "D:\a\1\s\BBI.PoseidonEnterprise.DataAccess.Orders\BBI.PoseidonEnterprise.DataAccess.Orders.nuspec" (Restore target) (1) ->
         D:\a\1\s\BBI.PoseidonEnterprise.DataAccess.Orders\BBI.PoseidonEnterprise.DataAccess.Orders.nuspec(2,1): error MSB4068: The element <package> is unrecognized, or not supported in this context.

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.07
##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
##[error]An error occurred while trying to pack the files.

Troubleshooting

this seems to be because the dotnet pack tasks expects a csproj or sln. and the nuspec has to be provided with -p:NugetConfig.

this command line works for us
dotnet pack solution1.sln -p:NugetConfig=Project1\Project1.nuspec

how ever the equivalent of this command that the pipeline dotnet task seem to execute is
dotnet pack Project1\Project1.nuspec

Expected behavior

task should not fail when "Path to csproj or nuspec file(s) to pack" field is populated with a nuspec file.

@bishal-pdMSFT
Copy link
Contributor

@NinadKavimandan

@NinadKavimandan
Copy link
Contributor

Hi @nandun5 - how will be using this task with nuspec file? will you be providing only nuspec file in the command, or do you want to include .sln file as well?

@nandun5
Copy link
Author

nandun5 commented Oct 20, 2020

we are providing the nuspec file with a wildcard as **/*.nuspec

@NinadKavimandan
Copy link
Contributor

okay. is the nuspec file taking care of the files to be packaged? so the command won't need the project/sln path?

@nandun5
Copy link
Author

nandun5 commented Oct 22, 2020

thats correct. in our pipelines, we only specify the nuspec file.

@NinadKavimandan
Copy link
Contributor

alright! thanks.

@tiwarishub
Copy link

Hi @nandun5 , we have merged the fix . Please let us know if you are still seeing this issue

@tiwarishub
Copy link

Closing as this is resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants