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

NuGet pack task doesn't include dependencies when using PackageReference #10301

Closed
satbai opened this issue May 2, 2019 · 4 comments
Closed
Labels
Area: ArtifactsPackages Azure Artifacts Packaging Team bug External

Comments

@satbai
Copy link
Contributor

satbai commented May 2, 2019

Repro steps:

  1. Create a project that references other NuGet packages using PackageReference in the project file.
  2. Use the v2.* NuGet task pack command to pack the project.
  3. Add a NuGet push task to push the package to a feed.
  4. View the pushed package in the feed. You should be able to see the referenced packages as dependencies but they're not there.

Notes:

@satbai satbai added bug Area: ArtifactsPackages Azure Artifacts Packaging Team labels May 2, 2019
@ghost ghost added the triage label May 2, 2019
@satbai satbai removed the triage label May 2, 2019
@Rzpeg
Copy link

Rzpeg commented May 9, 2019

@satbai The problem lies in nuget.exe itself. look: NuGet/Home#5979

The workaround that works for me is to patch nuspec with a powershell script, manually. This version supports only 1st level dependencies though.


Get-ChildItem -recurse | 
    where {$_.extension -eq ".nuspec"} |
    Foreach-Object {
        $PathToCsproj = $_.DirectoryName + "\" + $_.BaseName + ".csproj"
        $PathToNuSpec = $_.DirectoryName + "\" + $_.BaseName + ".nuspec"
        $csproj = [xml](Get-Content $PathToCsproj)
        $packageDependency = $csproj.Project.ItemGroup.PackageReference | Where-Object { $null -ne $_ }
        $nuspec = [xml](Get-Content $PathToNuSpec)

        $dep = $nuspec.CreateElement('dependencies', $nuspec.package.metadata.NamespaceURI)

        $packageDependency | ForEach-Object {
          $onedependency = $dep.AppendChild($nuspec.CreateElement('dependency', $nuspec.package.metadata.NamespaceURI))
          $onedependency.SetAttribute('id', $_.Include)
          $onedependency.SetAttribute('version', $_.Version)
        }

        $nuspec.package.metadata.AppendChild($dep)

        $nuspec.Save($PathToNuSpec)
    }

@satbai satbai added the External label May 9, 2019
@edufur
Copy link

edufur commented May 9, 2019

That workaround will not work for me as I have nested dependencies. What is being done to resolve this issue?

@satbai
Copy link
Contributor Author

satbai commented May 9, 2019

Looks like this bug should be part of this NuGet issue that bundles various issues with NuGet pack. @rrelyea, do you know if the nuget pack issues are being worked on yet?

@Rzpeg
Copy link

Rzpeg commented May 10, 2019

@edufur You could modify the script to process nested dependencies, just share it later, please.
I guess, nothing is being done to resolve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: ArtifactsPackages Azure Artifacts Packaging Team bug External
Projects
None yet
Development

No branches or pull requests

4 participants