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

Proper runtime support #2255

Merged
merged 31 commits into from
Apr 19, 2017

Conversation

matthid
Copy link
Member

@matthid matthid commented Apr 17, 2017

Part of #2256 but extra PR to make it easier to review.

@matthid
Copy link
Member Author

matthid commented Apr 17, 2017

OK this is crazy. If I got that correct some nuget packages can specify additional dependencies for a specific runtime in a file called runtime.json.
This looks like:

  "runtimes": {
    "win": {
      "Microsoft.Win32.Primitives": {
        "runtime.win.Microsoft.Win32.Primitives": "4.3.0"
      },

This means Paket needs to restore runtime.win.Microsoft.Win32.Primitives (which is not known through the regular dependency tree) to support the "win" rid (or any rid importing "win").

How do we do that in paket? I don't want to change the current resolver (as it is complicated enough). For now I'd try to implement this as a second phase (after regular restore has happened). This means that paket will ignore any runtime.json in the second layer (but doing this is insanity IMHO anyway)...

@forki please advise if that sounds like going into the wrong direction...

@forki
Copy link
Member

forki commented Apr 17, 2017 via email

@matthid
Copy link
Member Author

matthid commented Apr 17, 2017

And now what?

@matthid
Copy link
Member Author

matthid commented Apr 17, 2017

Ok this is an interesting start. I think I'll do the integration in the following way:

  • Add a new "runtimes" directive to the deps and lockfile
source https://nuget.org/api/v2
runtimes aot,win

nuget Newtonsoft.Json redirects: force
  • After regular install/update there will be another install/update step for the runtime dependencies for the enabled runtimes

This way restore doesn't need to be changed at all and the new packages will be in the regular resolution (I guess I need a new flag in the lockfile to "detect" if a package is in the regular resolution or if its picked because of runtime).

Still not sure if the default should be installing all packages for all runtimes OR no runtime at all. Currently I'm favoring all runtimes...

@matthid matthid requested review from cloudRoutine and forki April 17, 2017 21:08
@cloudRoutine
Copy link
Member

I'm not sure that it should default to installing for all runtimes (there are a ton of them) and in the absence of a specified runtime, isn't the default behavior to produce a FDD instead of a SCD ?

@@ -63,6 +63,11 @@
<FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\4.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</When>
<When Condition="$(TargetFSharpCoreVersion) &gt;= 4.4.1.0 AND $(TargetFSharpCoreVersion) &lt; 4.4.1.0 ">
Copy link
Member

Choose a reason for hiding this comment

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

These kinds of conditions don't work with xbuild, it's ridiculous that they don't and I'd rather write them this way too, but they end up causing more headaches than they're worth.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe once mono 5.0 drops (replacing xbuild with msbuild 15 by default) this can be considered, though

Copy link
Member

Choose a reason for hiding this comment

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

The target F# core version is a lot less useful when you're actually relying on paket and the fsharp.core nupkg to determine the version you're using

Copy link
Member Author

Choose a reason for hiding this comment

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

the travis build worked ...

@matthid
Copy link
Member Author

matthid commented Apr 17, 2017

I'm not sure that it should default to installing for all runtimes (there are a ton of them) and in the absence of a specified runtime, isn't the default behavior to produce a FDD instead of a SCD ?

Yes, but I'm not sure how they handle native dependencies in that case. From observing I'd say they ignore runtime deps (as in runtime.json) but they still copy stuff in the regular resolution....

@@ -0,0 +1,185 @@
namespace Paket

open Domain
Copy link
Member

Choose a reason for hiding this comment

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

@matthid can you add some doccoms for the functions in this file? I already know i'll have forgotten what half of this does in a few days

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I added some with c71d62b

RuntimeDependencies = dependencies }
| _ -> failwithf "unknwn stuff in runtime-description: %O" t.Value ]

let readRuntimeGraphJ (json:JObject) =
Copy link
Member

Choose a reason for hiding this comment

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

@matthid do you think it's possible to generalize this json graph structure a bit so we can use it to create the project.assets.json file as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

can you link an example?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

No I don't we should generalize here. But of course that info helps in generating those files as well.

@forki
Copy link
Member

forki commented Apr 18, 2017

Why do we need runtime in deps file? Shouldn't it just install the runtime we just use?

@matthid
Copy link
Member Author

matthid commented Apr 18, 2017

Why do we need runtime in deps file? Shouldn't it just install the runtime we just use?

Good point. But do you really want to read the fsproj file for info and then use that for resolving packages? What about multiple or no fsproj file? csproj? What about "old-style" fsproj? I don't even want to go into that. At least not in the first step (this PR) tbh...

@forki
Copy link
Member

forki commented Apr 18, 2017 via email

@matthid
Copy link
Member Author

matthid commented Apr 18, 2017

What is "the target it currently runs on"?

@forki
Copy link
Member

forki commented Apr 18, 2017

The OS if the machine

@matthid
Copy link
Member Author

matthid commented Apr 18, 2017

And what if I run on windows and want to publish my project for unix?

@forki
Copy link
Member

forki commented Apr 18, 2017 via email

@matthid
Copy link
Member Author

matthid commented Apr 18, 2017

So its the same problem you do another resolver step on "restore" to resolve the runtime deps. I think in pakets philosophy we should have already done that at that phase (IMHO) ... But it's up to you

@matthid
Copy link
Member Author

matthid commented Apr 18, 2017

I'd prefer the following when we get called by dotnet restore with an unknown runtime:

  • If in CI/noninteractive mode we fail when a runtime is not in the deps file and we are called
  • In interactive mode we ask the user if we should update the deps file and do an "install"

@forki
Copy link
Member

forki commented Apr 18, 2017 via email

@matthid
Copy link
Member Author

matthid commented Apr 18, 2017

@forki So we always resolve and lock every runtime down (during install/update). I'm fine with that, lets see how that works.
The lockfile might grow quite a bit with this.

But isn't install/update currently downloading the packages as well? Why would we change the behavior for the runtime deps?

I agree that our hook can have this behavior to only download whats needed.

It is really confusing, and I don't know if there is a good way how this fits into our world view...
On the other side I don't expect this PR to be perfect, just a start to experiment how things might work...

@forki
Copy link
Member

forki commented Apr 18, 2017

It does not fit our world view. That's the whole point.
It's aspnet team rushing a stupid concept into DNX without telling anyone. Now whole ecosystem is stuck with this shit and nuget team is busy building verified accounts for Microsoft and Oracle but nobody else.

[<assembly: AssemblyInformationalVersionAttribute("4.4.0")>]
[<assembly: AssemblyVersionAttribute("4.4.1")>]
[<assembly: AssemblyFileVersionAttribute("4.4.1")>]
[<assembly: AssemblyInformationalVersionAttribute("4.4.1")>]
Copy link
Member Author

Choose a reason for hiding this comment

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

@forki one suggestion across all your projects. Can you commit this immediately when you release (at the same time when you change release notes)? This way this doesn't always pop-up and makes merge conflicts.
Another way would be to gitignore those files and having only a default version (like 0.0.0.0) checked in for Visual Studio users...

| [ a; b ] -> k, f a b
| [ a ] -> k, a
| _ -> failwithf "This should never happen")
|> Map.ofSeq
Copy link
Member Author

Choose a reason for hiding this comment

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

Is there really no build-in function for that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@0x53A thanks :)

assert (optionsString = "isRuntimeDependency: true")
true, ""
else false, optionsString
parts.[0],isRuntimeDependency,InstallSettings.Parse(optionsString)
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe the parser and generator code should be cleaned up a bit in the future...

@matthid matthid changed the title WIP: Proper runtime support Proper runtime support Apr 19, 2017
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.

5 participants