Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation for #913 Paket.pack: add support for nuget dependencies conditional on target framework #2428

Merged
merged 5 commits into from
Jun 18, 2017

Conversation

bhugot
Copy link
Contributor

@bhugot bhugot commented Jun 16, 2017

Hi, this is a proposal for #913

it's going to fix a bit of #2394 too

the template should be 'type file'

and the syntax is the following

type file
id My.Thing
authors Bob McBob
description
    A longer description
    on two lines.
version
    1.0
dependencies 
    framework: net45
        FSharp.Core 4.3.1
        My.OtherThing
    framework: netstandard11
        FSharp.Core 4.3.1  

@bhugot
Copy link
Contributor Author

bhugot commented Jun 18, 2017

@forki Hi is it possible to review this one it's really a needed feature

Copy link
Member

@forki forki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very good. Only couple of minor nitpicks.

@@ -83,23 +84,45 @@ module internal NupkgWriter =
frameworkAssembliesList |> List.iter (buildFrameworkReferencesNode >> d.Add)
metadataNode.Add d

let buildDependencyNode (Id, requirement:VersionRequirement) =
let buildDependencyNode (id, requirement:VersionRequirement) =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please rename this thing. id is a function from the FSharp.Core and I think we should avoid confusion. Maybe name or idProperty or something like that



let buildDependencyNodes (excludedDependencies, add, dependencyList) =
let takeFirstOfThree (a,_,_) = a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a nice trick, but could you please manually inline this? I don't think we really need these functions here. Thx

|> List.iter (buildDependencyNode >> d.Add)
metadataNode.Add d
let groups = List.groupBy thirdOf3 dependencyList
if groups.Length = 1 && fst groups.Head = None then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please use pattern matching here?

let addDependency (templateFile : TemplateFile) (dependency : PackageName * VersionRequirement) =


let addDependency (templateFile : TemplateFile) (dependency : PackageName * VersionRequirement * FrameworkIdentifier option) =
match templateFile with
| CompleteTemplate(core, opt) ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Please get rid of firstOf3

static member ForNone = { Framework = None ; Dependencies = [] }
static member ForFramework framework = { Framework = framework ; Dependencies = [] }

let private getDependencieByLine (fileName, lockFile:LockFile,currentVersion:SemVerInfo option, specificVersions:Map<string, SemVerInfo>, line:string, framework:FrameworkIdentifier option)=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typo in function name

@@ -439,7 +439,6 @@ module FrameworkDetection =

open Logging
/// parse a string to construct a Netframework, NetCore, NetStandard, or other dotnet identifier
[<Obsolete "Use PlatformMatching.extractPlatforms instead">]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

@bhugot
Copy link
Contributor Author

bhugot commented Jun 18, 2017

Hope the change are good for you, my first time with F# so I don't know all the good way to do.

@forki
Copy link
Member

forki commented Jun 18, 2017 via email

@bhugot
Copy link
Contributor Author

bhugot commented Jun 18, 2017

Added documentation.

@forki forki merged commit 6bdcf80 into fsprojects:master Jun 18, 2017
@forki
Copy link
Member

forki commented Jun 18, 2017

thanks a lot! released in 5.1

@bhugot
Copy link
Contributor Author

bhugot commented Jun 18, 2017

No problems it s helping my team too

@matthid
Copy link
Member

matthid commented Sep 3, 2017

Obviously I'm a bit late but shouldn't we be able to calculate the correct groups from the framework restrictions ourself? All we would need is the list of frameworks the package contains binaries for. Rest could be figured out by paket itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants