Skip to content

Commit 099abd6

Browse files
KN4CK3RBenjamin Heemann
and
Benjamin Heemann
committed
Read flat dependencies.
Co-authored-by: Benjamin Heemann <benjamin.heemann@raith.de>
1 parent 663acd0 commit 099abd6

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

modules/packages/nuget/metadata.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ type Dependency struct {
7171
Version string `json:"version"`
7272
}
7373

74+
// https://learn.microsoft.com/en-us/nuget/reference/nuspec
7475
type nuspecPackage struct {
7576
Metadata struct {
7677
ID string `xml:"id"`
@@ -89,6 +90,11 @@ type nuspecPackage struct {
8990
URL string `xml:"url,attr"`
9091
} `xml:"repository"`
9192
Dependencies struct {
93+
Dependency []struct {
94+
ID string `xml:"id,attr"`
95+
Version string `xml:"version,attr"`
96+
Exclude string `xml:"exclude,attr"`
97+
} `xml:"dependency"`
9298
Group []struct {
9399
TargetFramework string `xml:"targetFramework,attr"`
94100
Dependency []struct {
@@ -166,6 +172,19 @@ func ParseNuspecMetaData(r io.Reader) (*Package, error) {
166172
Dependencies: make(map[string][]Dependency),
167173
}
168174

175+
if len(p.Metadata.Dependencies.Dependency) > 0 {
176+
deps := make([]Dependency, 0, len(p.Metadata.Dependencies.Dependency))
177+
for _, dep := range p.Metadata.Dependencies.Dependency {
178+
if dep.ID == "" || dep.Version == "" {
179+
continue
180+
}
181+
deps = append(deps, Dependency{
182+
ID: dep.ID,
183+
Version: dep.Version,
184+
})
185+
}
186+
m.Dependencies[""] = deps
187+
}
169188
for _, group := range p.Metadata.Dependencies.Group {
170189
deps := make([]Dependency, 0, len(group.Dependency))
171190
for _, dep := range group.Dependency {

0 commit comments

Comments
 (0)