From 89d99ffcfb9e612456099d4854ea3eeedd374bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4ger?= Date: Thu, 28 Nov 2024 01:42:50 +0100 Subject: [PATCH] Add support for icon in paket.template. --- docs/content/template-files.md | 3 ++- src/Paket.Core/Packaging/NupkgWriter.fs | 1 + src/Paket.Core/PaketConfigFiles/ProjectFile.fs | 1 + src/Paket.Core/PaketConfigFiles/TemplateFile.fs | 3 +++ tests/Paket.Tests/Packaging/NuspecWriterSpecs.fs | 2 ++ tests/Paket.Tests/Packaging/TemplateFileParsing.fs | 3 +++ 6 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/content/template-files.md b/docs/content/template-files.md index ccfb79a6d4..e45dbf630c 100644 --- a/docs/content/template-files.md +++ b/docs/content/template-files.md @@ -113,7 +113,8 @@ field of the same name in the `.nupkg`. * `readme`: This is a path to a readme file *in* the package. It should be added with the `files` block (see below). * `language` * `projectUrl` -* `iconUrl` +* `iconUrl` (deprecated by NuGet) +* `icon` This is a path to an image file *in* the package. It should be added with the `files` block (see below). * `licenseExpression`: More info on what you can specify: * `licenseUrl` (deprecated by NuGet) * `repositoryType` diff --git a/src/Paket.Core/Packaging/NupkgWriter.fs b/src/Paket.Core/Packaging/NupkgWriter.fs index 52266e1049..a0e847a06b 100644 --- a/src/Paket.Core/Packaging/NupkgWriter.fs +++ b/src/Paket.Core/Packaging/NupkgWriter.fs @@ -186,6 +186,7 @@ module internal NupkgWriter = (!!?) "projectUrl" optional.ProjectUrl (!!?) "iconUrl" optional.IconUrl + (!!?) "icon" optional.Icon if optional.RequireLicenseAcceptance then !! "requireLicenseAcceptance" "true" !! "description" core.Description diff --git a/src/Paket.Core/PaketConfigFiles/ProjectFile.fs b/src/Paket.Core/PaketConfigFiles/ProjectFile.fs index 0c3ad3f1db..a2c8d61997 100644 --- a/src/Paket.Core/PaketConfigFiles/ProjectFile.fs +++ b/src/Paket.Core/PaketConfigFiles/ProjectFile.fs @@ -2095,6 +2095,7 @@ type ProjectFile with Language = prop "Langauge" ProjectUrl = prop "ProjectUrl" IconUrl = prop "IconUrl" + Icon = prop "Icon" LicenseExpression = prop "LicenseExpression" LicenseUrl = prop "LicenseUrl" Copyright = prop "Copyright" diff --git a/src/Paket.Core/PaketConfigFiles/TemplateFile.fs b/src/Paket.Core/PaketConfigFiles/TemplateFile.fs index 196d2dc36a..0b1504a4b5 100644 --- a/src/Paket.Core/PaketConfigFiles/TemplateFile.fs +++ b/src/Paket.Core/PaketConfigFiles/TemplateFile.fs @@ -145,6 +145,7 @@ type OptionalPackagingInfo = Language : string option ProjectUrl : string option IconUrl : string option + Icon : string option LicenseExpression : string option LicenseUrl : string option RepositoryUrl : string option @@ -183,6 +184,7 @@ type OptionalPackagingInfo = RepositoryBranch = None RepositoryCommit = None IconUrl = None + Icon = None Copyright = None RequireLicenseAcceptance = false Tags = [] @@ -543,6 +545,7 @@ module internal TemplateFile = Language = get "language" ProjectUrl = get "projectUrl" IconUrl = get "iconUrl" + Icon = get "icon" RepositoryType = get "repositoryType" RepositoryUrl = get "repositoryUrl" RepositoryBranch = get "repositoryBranch" diff --git a/tests/Paket.Tests/Packaging/NuspecWriterSpecs.fs b/tests/Paket.Tests/Packaging/NuspecWriterSpecs.fs index dc8056f539..29cb9670e5 100644 --- a/tests/Paket.Tests/Packaging/NuspecWriterSpecs.fs +++ b/tests/Paket.Tests/Packaging/NuspecWriterSpecs.fs @@ -362,6 +362,7 @@ let ``should not serialize all properties``() = MIT http://www.somewhere.com http://www.somewhere.com/Icon + some/icon.png true A description summary @@ -397,6 +398,7 @@ second line ProjectUrl = Some "http://www.somewhere.com" LicenseExpression = Some "MIT" IconUrl = Some "http://www.somewhere.com/Icon" + Icon = Some "some/icon.png" Copyright = Some "Paket owners 2015" RequireLicenseAcceptance = true References = ["file1.dll";"file2.dll"] diff --git a/tests/Paket.Tests/Packaging/TemplateFileParsing.fs b/tests/Paket.Tests/Packaging/TemplateFileParsing.fs index 6fb049ca84..3a597815ff 100644 --- a/tests/Paket.Tests/Packaging/TemplateFileParsing.fs +++ b/tests/Paket.Tests/Packaging/TemplateFileParsing.fs @@ -151,6 +151,8 @@ projectUrl http://github.com/fsprojects/Chessie iconUrl https://raw.githubusercontent.com/fsprojects/Chessie/master/docs/files/img/logo.png +icon + some/icon.png licenseExpression Unlicense requireLicenseAcceptance @@ -199,6 +201,7 @@ let ``Optional fields are read`` (fileContent : string) = sut.Summary |> shouldEqual (Some "Railway-oriented programming for .NET") sut.Readme |> shouldEqual (Some "README.md") sut.IconUrl |> shouldEqual (Some "https://raw.githubusercontent.com/fsprojects/Chessie/master/docs/files/img/logo.png") + sut.Icon |> shouldEqual (Some "some/icon.png") sut.LicenseExpression |> shouldEqual (Some "Unlicense") sut.ProjectUrl |> shouldEqual (Some "http://github.com/fsprojects/Chessie") sut.Tags |> shouldEqual ["rop";"fsharp";"F#"]