Skip to content

Commit c1f6b56

Browse files
committed
Add repository to template file - fixes #3707
1 parent dada341 commit c1f6b56

4 files changed

Lines changed: 240 additions & 223 deletions

File tree

‎docs/content/template-files.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ field of the same name in the `.nupkg`.
114114
* `projectUrl`
115115
* `iconUrl`
116116
* `licenseUrl`
117+
* `repositoryType`
118+
* `repositoryUrl`
117119
* `copyright`
118120
* `requireLicenseAcceptance` (`true` or `false`)
119121
* `tags`

‎src/Paket.Core/Packaging/NupkgWriter.fs‎

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ module internal NupkgWriter =
9595
dep.SetAttributeValue(XName.Get "version", version)
9696
dep
9797

98-
let buildGroupNode (framework:FrameworkIdentifier option, add) =
98+
let buildGroupNode (framework:FrameworkIdentifier option, add) =
9999
let g = XElement(ns + "group")
100100
match framework with
101101
| Some f -> g.SetAttributeValue(XName.Get "targetFramework", f.ToString())
@@ -105,7 +105,7 @@ module internal NupkgWriter =
105105

106106
let aggregateDependencies excludedDependencies dependencyList =
107107
dependencyList
108-
|> List.filter (fun (a, _) -> Set.contains a excludedDependencies |> not)
108+
|> List.filter (fun (a, _) -> Set.contains a excludedDependencies |> not)
109109

110110
let buildDependencyNodes (add, dependencies) =
111111
dependencies
@@ -125,7 +125,7 @@ module internal NupkgWriter =
125125
| [g] when Option.isNone g.Framework ->
126126
let deps = aggregateDependencies excludedDependencies g.Dependencies
127127
buildDependencyNodes(d.Add, deps)
128-
| _ ->
128+
| _ ->
129129
for g in dependencyGroups do
130130
buildDependencyNodesByGroup excludedDependencies d.Add g
131131
metadataNode.Add d
@@ -138,7 +138,7 @@ module internal NupkgWriter =
138138
let buildReferencesNode referenceList =
139139
if List.isEmpty referenceList then () else
140140
let d = XElement(ns + "references")
141-
for r in referenceList do
141+
for r in referenceList do
142142
d.Add(buildReferenceNode r)
143143
metadataNode.Add d
144144

@@ -162,6 +162,14 @@ module internal NupkgWriter =
162162
!! "authors" (core.Authors |> String.concat ", ")
163163
if optional.Owners <> [] then !! "owners" (String.Join(", ",optional.Owners))
164164
(!!?) "licenseUrl" optional.LicenseUrl
165+
match optional.RepositoryType, optional.RepositoryUrl with
166+
| Some t, Some url ->
167+
let d = XElement(ns + "repository")
168+
d.SetAttributeValue(XName.Get "type", t)
169+
d.SetAttributeValue(XName.Get "url", url)
170+
metadataNode.Add d
171+
| _ -> ()
172+
165173
(!!?) "projectUrl" optional.ProjectUrl
166174
(!!?) "iconUrl" optional.IconUrl
167175
if optional.RequireLicenseAcceptance then
@@ -385,7 +393,7 @@ module internal NupkgWriter =
385393
outputPath
386394

387395
[<AutoOpen>]
388-
module NuspecExtensions =
396+
module NuspecExtensions =
389397
open NupkgWriter
390398

391399
type Nuspec with
@@ -396,7 +404,7 @@ module NuspecExtensions =
396404
Id + ".nuspec", nuspecDoc ({coreInfo with Id = Id}, optionalInfo)
397405
| {Contents = ProjectInfo(projectInfo, optionalInfo) } ->
398406
Id + ".nuspec", nuspecDoc (projectInfo.ToCoreInfo Id, optionalInfo)
399-
407+
400408

401409
static member FromProject (projectPath:string, dependenciesFile:DependenciesFile) =
402410
match ProjectFile.TryLoad projectPath with
@@ -406,22 +414,21 @@ module NuspecExtensions =
406414
project.FindReferencesFile ()
407415
|> Option.map (fun refsPath ->
408416
let references = ReferencesFile.FromFile refsPath
409-
references.Groups |> Seq.collect (fun kvp ->
410-
kvp.Value.NugetPackages |> List.choose (fun pkg ->
417+
references.Groups |> Seq.collect (fun kvp ->
418+
kvp.Value.NugetPackages |> List.choose (fun pkg ->
411419
dependenciesFile.TryGetPackage(kvp.Key,pkg.Name)
412420
|> Option.map (fun verreq -> pkg.Name,verreq.VersionRequirement)))
413421
|> List.ofSeq
414422
) |> Option.defaultValue []
415423
let projectInfo, optionalInfo = project.GetTemplateMetadata ()
416424

417-
let optionalInfo =
425+
let optionalInfo =
418426
{ optionalInfo with
419427
DependencyGroups = [ OptionalDependencyGroup.For None packages ]
420428
}
421429
let name = Path.GetFileNameWithoutExtension project.Name
422430
// TODO - this might be the point to add in some info from the
423431
// lock and dependencies fiels that weren't in the project file
424432
name + ".nuspec", nuspecDoc (projectInfo.ToCoreInfo name, optionalInfo )
425-
426-
427-
433+
434+

0 commit comments

Comments
 (0)