diff --git a/docs/content/template-files.md b/docs/content/template-files.md index e6d98709e6..1015de8db6 100644 --- a/docs/content/template-files.md +++ b/docs/content/template-files.md @@ -33,7 +33,7 @@ A `paket.template` file using `type project` may look like this: ```text type project -licenseUrl http://opensource.org/licenses/MIT +licenseExpression MIT ``` This template file will be used to create a `.nupkg` @@ -113,7 +113,8 @@ field of the same name in the `.nupkg`. * `language` * `projectUrl` * `iconUrl` -* `licenseUrl` +* `licenseExpression`: More info on what you can specify: +* `licenseUrl` (deprecated by NuGet) * `repositoryType` * `repositoryUrl` * `copyright` diff --git a/src/Paket.Core/Packaging/NupkgWriter.fs b/src/Paket.Core/Packaging/NupkgWriter.fs index fc60f314fc..24e30f0c90 100644 --- a/src/Paket.Core/Packaging/NupkgWriter.fs +++ b/src/Paket.Core/Packaging/NupkgWriter.fs @@ -161,6 +161,13 @@ module internal NupkgWriter = (!!?) "title" optional.Title !! "authors" (core.Authors |> String.concat ", ") if optional.Owners <> [] then !! "owners" (String.Join(", ",optional.Owners)) + match optional.LicenseExpression with + | Some licenseExpression -> + let el = XElement(ns + "license") + el.SetAttributeValue(XName.Get "type", "expression") + el.SetValue(licenseExpression) + metadataNode.Add el + | _ -> () (!!?) "licenseUrl" optional.LicenseUrl match optional.RepositoryType, optional.RepositoryUrl with | Some t, Some url -> diff --git a/src/Paket.Core/PaketConfigFiles/ProjectFile.fs b/src/Paket.Core/PaketConfigFiles/ProjectFile.fs index dd13fe9fca..58c6b6ccda 100644 --- a/src/Paket.Core/PaketConfigFiles/ProjectFile.fs +++ b/src/Paket.Core/PaketConfigFiles/ProjectFile.fs @@ -2090,6 +2090,7 @@ type ProjectFile with Language = prop "Langauge" ProjectUrl = prop "ProjectUrl" IconUrl = prop "IconUrl" + LicenseExpression = prop "LicenseExpression" LicenseUrl = prop "LicenseUrl" Copyright = prop "Copyright" RepositoryType = prop "RepositoryType" diff --git a/src/Paket.Core/PaketConfigFiles/TemplateFile.fs b/src/Paket.Core/PaketConfigFiles/TemplateFile.fs index d2482a1136..b45d0b42d5 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 + LicenseExpression : string option LicenseUrl : string option RepositoryUrl : string option RepositoryType : string option @@ -172,6 +173,7 @@ type OptionalPackagingInfo = Summary = None Language = None ProjectUrl = None + LicenseExpression = None LicenseUrl = None RepositoryUrl = None RepositoryType = None @@ -537,6 +539,7 @@ module internal TemplateFile = IconUrl = get "iconUrl" RepositoryType = get "repositoryType" RepositoryUrl = get "repositoryUrl" + LicenseExpression = get "licenseExpression" LicenseUrl = get "licenseUrl" Copyright = get "copyright" RequireLicenseAcceptance = requireLicenseAcceptance diff --git a/tests/Paket.Tests/Packaging/NuspecWriterSpecs.fs b/tests/Paket.Tests/Packaging/NuspecWriterSpecs.fs index c09934776a..42794f017a 100644 --- a/tests/Paket.Tests/Packaging/NuspecWriterSpecs.fs +++ b/tests/Paket.Tests/Packaging/NuspecWriterSpecs.fs @@ -363,7 +363,7 @@ let ``should not serialize all properties``() = A title Michael, Steffen Steffen, Alex - http://www.somewhere.com/license.html + MIT http://www.somewhere.com http://www.somewhere.com/Icon true @@ -397,7 +397,7 @@ second line Summary = Some "summary" Language = Some "en-US" ProjectUrl = Some "http://www.somewhere.com" - LicenseUrl = Some "http://www.somewhere.com/license.html" + LicenseExpression = Some "MIT" IconUrl = Some "http://www.somewhere.com/Icon" Copyright = Some "Paket owners 2015" RequireLicenseAcceptance = true diff --git a/tests/Paket.Tests/Packaging/TemplateFileParsing.fs b/tests/Paket.Tests/Packaging/TemplateFileParsing.fs index 079b54dc41..fcf90728d4 100644 --- a/tests/Paket.Tests/Packaging/TemplateFileParsing.fs +++ b/tests/Paket.Tests/Packaging/TemplateFileParsing.fs @@ -154,8 +154,8 @@ projectUrl http://github.com/fsprojects/Chessie iconUrl https://raw.githubusercontent.com/fsprojects/Chessie/master/docs/files/img/logo.png -licenseUrl - http://github.com/fsprojects/Chessie/blob/master/LICENSE.txt +licenseExpression + Unlicense requireLicenseAcceptance false copyright @@ -199,7 +199,7 @@ let ``Optional fields are read`` (fileContent : string) = sut.Copyright |> shouldEqual (Some "Copyright 2015") sut.Summary |> shouldEqual (Some "Railway-oriented programming for .NET") sut.IconUrl |> shouldEqual (Some "https://raw.githubusercontent.com/fsprojects/Chessie/master/docs/files/img/logo.png") - sut.LicenseUrl |> shouldEqual (Some "http://github.com/fsprojects/Chessie/blob/master/LICENSE.txt") + sut.LicenseExpression |> shouldEqual (Some "Unlicense") sut.ProjectUrl |> shouldEqual (Some "http://github.com/fsprojects/Chessie") sut.Tags |> shouldEqual ["rop";"fsharp";"F#"] sut.Owners |> shouldEqual ["Steffen Forkmann";"Max Malook";"Tomasz Heimowski"]