Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions integrationtests/Paket.IntegrationTests/PackSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -927,3 +927,28 @@ let ``#3707 allows repositoryUrl``() =
let expected = """<repository type="git" url="https://github.com/my-org/my-custom-repo" />"""
if not (nuspec.Contains expected) then
failwith nuspec

[<Test>]
let ``#3710 specify license expression and icon``() =
let scenario = "i003710-license-expression-and-icon"

let outPath = Path.Combine(scenarioTempPath scenario,"out")
let templatePath = Path.Combine(scenarioTempPath scenario,"src", "A.Source", "paket.template")
use __ = paket ("pack version 1.0.0 output \"" + outPath + "\" -v") scenario |> fst

let package = Path.Combine(outPath, "A.Source.1.0.0.nupkg")

let unzippedNupkgPath = Path.Combine(outPath, "Extracted")
ZipFile.ExtractToDirectory(package, unzippedNupkgPath)

let nuspecFile = FileInfo(Path.Combine(unzippedNupkgPath, "A.Source.nuspec"))
let nuspec = File.ReadAllText(nuspecFile.FullName)
let expectedLicense = """<license type="expression">MIT</license>"""
let expectedIcon = """<icon>guy-fieri.jpg</icon>"""
let expectedFile = """<file src="guy-fieri.jpg" target="img" />"""
if not (nuspec.Contains expectedLicense) then
failwith ("nuspec doesn't have the license expression.\n" + nuspec)
if not (nuspec.Contains expectedIcon) then
failwith ("nuspec doesn't have the icon.\n" + nuspec)
if not (nuspec.Contains expectedFile) then
failwith ("nuspec doesn't have the icon file.\n" + nuspec)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source https://www.nuget.org/api/v2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
type file
id A.Source
owners Team
authors Team
projectUrl
https://github.com/
icon
guy-fieri.jpg
license
MIT
repositoryType
git
repositoryUrl
https://github.com/my-org/my-custom-repo
requireLicenseAcceptance
false
copyright
Copyright 2015
tags
tag
summary
summary
description
Project has no description
files
../A/**/*.cs ==> ./A
guy-fieri.jpg ==> img/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// just an empty file i expect to be packaged
15 changes: 15 additions & 0 deletions src/Paket.Core/Packaging/NupkgWriter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,20 @@ module internal NupkgWriter =
!! "authors" (core.Authors |> String.concat ", ")
if optional.Owners <> [] then !! "owners" (String.Join(", ",optional.Owners))
(!!?) "licenseUrl" optional.LicenseUrl

match optional.License, optional.LicenseFile with
| Some l, None ->
let d = XElement(ns + "license", l)
d.SetAttributeValue(XName.Get "type", "expression")
metadataNode.Add d
| None, Some lf ->
let d = XElement(ns + "license", lf)
d.SetAttributeValue(XName.Get "type", "file")
metadataNode.Add d
| Some _, Some _ ->
raise (Exception("Cannot specify both a license and licenseFile attribute. Pick one or the other."))
| None, None -> ()

match optional.RepositoryType, optional.RepositoryUrl with
| Some t, Some url ->
let d = XElement(ns + "repository")
Expand All @@ -172,6 +186,7 @@ module internal NupkgWriter =

(!!?) "projectUrl" optional.ProjectUrl
(!!?) "iconUrl" optional.IconUrl
(!!?) "icon" optional.Icon
if optional.RequireLicenseAcceptance then
!! "requireLicenseAcceptance" "true"
!! "description" core.Description
Expand Down
3 changes: 3 additions & 0 deletions src/Paket.Core/PaketConfigFiles/ProjectFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2068,7 +2068,10 @@ type ProjectFile with
Language = prop "Langauge"
ProjectUrl = prop "ProjectUrl"
IconUrl = prop "IconUrl"
Icon = prop "IconUrl"
LicenseUrl = prop "LicenseUrl"
License = prop "License"
LicenseFile = prop "LicenseFile"
Copyright = prop "Copyright"
RepositoryType = prop "RepositoryType"
RepositoryUrl = prop "RepositoryUrl"
Expand Down
9 changes: 9 additions & 0 deletions src/Paket.Core/PaketConfigFiles/TemplateFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ type OptionalPackagingInfo =
Language : string option
ProjectUrl : string option
IconUrl : string option
Icon : string option
LicenseUrl : string option
License : string option
LicenseFile : string option
RepositoryUrl : string option
RepositoryType : string option
Copyright : string option
Expand Down Expand Up @@ -173,9 +176,12 @@ type OptionalPackagingInfo =
Language = None
ProjectUrl = None
LicenseUrl = None
License = None
LicenseFile = None
RepositoryUrl = None
RepositoryType = None
IconUrl = None
Icon = None
Copyright = None
RequireLicenseAcceptance = false
Tags = []
Expand Down Expand Up @@ -535,9 +541,12 @@ module internal TemplateFile =
Language = get "language"
ProjectUrl = get "projectUrl"
IconUrl = get "iconUrl"
Icon = get "icon"
RepositoryType = get "repositoryType"
RepositoryUrl = get "repositoryUrl"
LicenseUrl = get "licenseUrl"
License = get "license"
LicenseFile = get "licenseFile"
Copyright = get "copyright"
RequireLicenseAcceptance = requireLicenseAcceptance
Tags = tags
Expand Down