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
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4de3516
add rid and graph parameters
matthid Apr 17, 2017
b99bc0b
add parsing of the runtime graph
matthid Apr 17, 2017
e916e0d
implement merge
matthid Apr 17, 2017
25e4c4a
add newtonsoft json dep to unit test project
matthid Apr 17, 2017
2db9f1f
use vs2017 image for F# 4.1 support
matthid Apr 17, 2017
51a4768
use F#4.1 for paket.core
matthid Apr 17, 2017
deb17ce
commit what I have for now
matthid Apr 17, 2017
554a503
commit the current idea
matthid Apr 18, 2017
898d42e
combine resolutions
matthid Apr 18, 2017
4b0c411
make it build on netcore as well
matthid Apr 18, 2017
320151f
fix build of test projects
matthid Apr 18, 2017
8f0435a
fix unit tests
matthid Apr 18, 2017
244cb1a
fix more real-life tests
matthid Apr 18, 2017
b5a96a2
add comment
matthid Apr 18, 2017
981e0e3
Merge branch 'fix_dotnetcore' into add_runtime_support
matthid Apr 18, 2017
c71d62b
add comments to RuntimeGraph
matthid Apr 18, 2017
1af9f33
make local nuget feeds work as well.
matthid Apr 18, 2017
90aada1
some cleanup
matthid Apr 18, 2017
db0fe01
update netcore project file :/
matthid Apr 18, 2017
80dbd1b
add some tests for runtime dependency resolution.
matthid Apr 18, 2017
88b2430
add runtime dependencies to the lockfile and mark them with 'isRuntim…
matthid Apr 18, 2017
d717814
move InstallModel.fs after RuntimeGraph.fs as we will shortly depend …
matthid Apr 18, 2017
5b50f8e
cleanup InstallModel again and prepare for runtime support...
matthid Apr 18, 2017
dad17ae
write some release notes
matthid Apr 19, 2017
e81cda9
more runtime support in installmodel
matthid Apr 19, 2017
2a4eb54
appveyor, please build a package for me and publish it.
matthid Apr 19, 2017
35e28f3
finish runtime support in installmodel, fix exlude support
matthid Apr 19, 2017
48515bd
cleanup and fixup of 'should understand aot in runtimes' test
matthid Apr 19, 2017
9743b21
make two builds: one which fast publishes the package and one which r…
matthid Apr 19, 2017
3473281
tell appveyor that this are nuget packages.
matthid Apr 19, 2017
71673ce
verbose is a bit too much
matthid Apr 19, 2017
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
6 changes: 3 additions & 3 deletions .paket/Paket.Restore.targets
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<ContinuePackingAfterGeneratingNuspec>false</ContinuePackingAfterGeneratingNuspec>
</PropertyGroup>
</Target>

<Target Name="PaketOverrideNuspec" AfterTargets="GenerateNuspec" >
<PropertyGroup>
<PaketReferencesFilePath>$(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).references</PaketReferencesFilePath>
Expand All @@ -57,11 +57,11 @@
</ItemGroup>

<Exec Command='$(PaketCommand) fix-nuspec file "@(_NuspecFiles)" references-file "$(PaketReferencesFilePath)" ' />

<ConvertToAbsolutePath Condition="@(_NuspecFiles) != ''" Paths="@(_NuspecFiles)">
<Output TaskParameter="AbsolutePaths" PropertyName="NuspecFileAbsolutePath" />
</ConvertToAbsolutePath>

<!-- Call Pack -->
<PackTask PackItem="$(PackProjectInputFile)"
PackageFiles="@(_PackageFiles)"
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
image: Visual Studio 2017
init:
- git config --global core.autocrlf input
build_script:
Expand Down
2 changes: 2 additions & 0 deletions integrationtests/Paket.IntegrationTests/OutdatedSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ let ``#183 outdated without params``() =
msg |> shouldContainText "FSharp.Formatting 2.4 ->"

[<Test>]
[<Platform "Mono">] // PATH TOO LONG on Windows...
let ``#183 outdated --ignore-constraint``() =
let msg = paket "outdated --ignore-constraints" "i000183-outdated-with-special-parameters"
msg.Contains("Newtonsoft.Json 6.0.7 -> 6.0.8") |> shouldEqual false


[<Test>]
[<Platform "Mono">] // PATH TOO LONG on Windows...
let ``#183 outdated --include-prereleases``() =
let msg = paket "outdated --include-prereleases" "i000183-outdated-with-special-parameters"
msg |> shouldContainText "Newtonsoft.Json 6.0.7 ->"
Expand Down
12 changes: 6 additions & 6 deletions src/Paket.Bootstrapper/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
[assembly: AssemblyTitleAttribute("Paket.Bootstrapper")]
[assembly: AssemblyProductAttribute("Paket")]
[assembly: AssemblyDescriptionAttribute("A dependency manager for .NET with support for NuGet packages and git repositories.")]
[assembly: AssemblyVersionAttribute("4.4.0")]
[assembly: AssemblyFileVersionAttribute("4.4.0")]
[assembly: AssemblyInformationalVersionAttribute("4.4.0")]
[assembly: AssemblyVersionAttribute("4.4.1")]
[assembly: AssemblyFileVersionAttribute("4.4.1")]
[assembly: AssemblyInformationalVersionAttribute("4.4.1")]
namespace System {
internal static class AssemblyVersionInformation {
internal const System.String AssemblyTitle = "Paket.Bootstrapper";
internal const System.String AssemblyProduct = "Paket";
internal const System.String AssemblyDescription = "A dependency manager for .NET with support for NuGet packages and git repositories.";
internal const System.String AssemblyVersion = "4.4.0";
internal const System.String AssemblyFileVersion = "4.4.0";
internal const System.String AssemblyInformationalVersion = "4.4.0";
internal const System.String AssemblyVersion = "4.4.1";
internal const System.String AssemblyFileVersion = "4.4.1";
internal const System.String AssemblyInformationalVersion = "4.4.1";
}
}
7 changes: 4 additions & 3 deletions src/Paket.Core.preview3/Paket.Core.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,17 @@
<Compile Include="$(PaketCoreSourcesDir)\InstallModel.fs" />
<Compile Include="$(PaketCoreSourcesDir)\DependenciesTypes.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Parsers/DependenciesFileParser.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Nuget.fs" />
<Compile Include="$(PaketCoreSourcesDir)\NuGetV3.fs" />
<Compile Include="$(PaketCoreSourcesDir)\NuGetV2.fs" />
<Compile Include="$(PaketCoreSourcesDir)\RuntimeGraph.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Files/ReferencesFile.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Files/SolutionFile.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Files/LockFile.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Files/TemplateFile.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Files/ProjectFile.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Files/DependenciesFile.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Files/PackagesConfigFile.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Nuget.fs" />
<Compile Include="$(PaketCoreSourcesDir)\NuGetV3.fs" />
<Compile Include="$(PaketCoreSourcesDir)\NuGetV2.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Queries.fs" />
<Compile Include="$(PaketCoreSourcesDir)\ScriptGeneration.fs" />
<Compile Include="$(PaketCoreSourcesDir)\LocalFile.fs" />
Expand Down
12 changes: 6 additions & 6 deletions src/Paket.Core/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ open System.Reflection
[<assembly: AssemblyProductAttribute("Paket")>]
[<assembly: AssemblyCompanyAttribute("Paket team")>]
[<assembly: AssemblyDescriptionAttribute("A dependency manager for .NET with support for NuGet packages and git repositories.")>]
[<assembly: AssemblyVersionAttribute("4.4.0")>]
[<assembly: AssemblyFileVersionAttribute("4.4.0")>]
[<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...

do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "Paket.Core"
let [<Literal>] AssemblyProduct = "Paket"
let [<Literal>] AssemblyCompany = "Paket team"
let [<Literal>] AssemblyDescription = "A dependency manager for .NET with support for NuGet packages and git repositories."
let [<Literal>] AssemblyVersion = "4.4.0"
let [<Literal>] AssemblyFileVersion = "4.4.0"
let [<Literal>] AssemblyInformationalVersion = "4.4.0"
let [<Literal>] AssemblyVersion = "4.4.1"
let [<Literal>] AssemblyFileVersion = "4.4.1"
let [<Literal>] AssemblyInformationalVersion = "4.4.1"
66 changes: 64 additions & 2 deletions src/Paket.Core/Files/DependenciesFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ type DependenciesFile(fileName,groups:Map<GroupName,DependenciesGroup>, textRepr
member __.FileName = fileName
member __.Lines = textRepresentation

member this.Resolve(force, getSha1, getVersionF, getPackageDetailsF, groupsToResolve:Map<GroupName,_>, updateMode) =
member this.Resolve(force, getSha1, getVersionF, getPackageDetailsF, getPackageRuntimeGraph, groupsToResolve:Map<GroupName,_>, updateMode) =
let resolveGroup groupName _ =
let group = this.GetGroup groupName

Expand Down Expand Up @@ -206,6 +206,7 @@ type DependenciesFile(fileName,groups:Map<GroupName,DependenciesGroup>, textRepr
if String.IsNullOrWhiteSpace fileName |> not then
RemoteDownload.DownloadSourceFiles(Path.GetDirectoryName fileName, groupName, force, remoteFiles)

// Step 1 Package resolution
let resolution =
PackageResolver.Resolve(
getVersionF,
Expand All @@ -217,7 +218,68 @@ type DependenciesFile(fileName,groups:Map<GroupName,DependenciesGroup>, textRepr
remoteDependencies @ group.Packages |> Set.ofList,
updateMode)

{ ResolvedPackages = resolution
// Step 2 Runtime package resolution, see https://github.com/fsprojects/Paket/pull/2255
let runtimeResolution =
match resolution with
| Resolution.Ok resolved ->
// runtime resolution step
let runtimeGraph = // setting this variable to empty is the fastest way to disable runtime deps resolution
resolved
|> Map.toSeq |> Seq.map snd
|> Seq.choose (getPackageRuntimeGraph groupName)
|> RuntimeGraph.mergeSeq
//RuntimeGraph.Empty
// 3. Resolve runtime deps and add it to the resolution
let rids = RuntimeGraph.getKnownRids runtimeGraph
let runtimeDeps =
resolved
|> Map.toSeq |> Seq.map snd
|> Seq.collect (fun p ->
rids
|> Seq.collect(fun rid -> RuntimeGraph.findRuntimeDependencies rid p.Name runtimeGraph))
|> Seq.map (fun (name, versionReq) ->
{ Name = name
VersionRequirement = versionReq
ResolverStrategyForDirectDependencies = Some ResolverStrategy.Max
ResolverStrategyForTransitives = Some ResolverStrategy.Max
Parent = PackageRequirementSource.DependenciesFile fileName
Graph = []
Sources = group.Sources
Settings = group.Options.Settings })
|> Seq.toList

// TODO: We might want a way here to tell the resolver:
// "We don't really want Package A, but if you need it take Version X (from our resolution above)"
// Maybe we can actually do this by modifying the "getVersionF" callback?
let runtimeResolution =
PackageResolver.Resolve(
getVersionF,
getPackageDetailsF,
groupName,
group.Options.ResolverStrategyForDirectDependencies,
group.Options.ResolverStrategyForTransitives,
group.Options.Settings.FrameworkRestrictions,
runtimeDeps |> Set.ofList,
updateMode)

// Combine with existing resolution and mark runtime packages.
// TODO: Warn if a package is part of both resolutions?
// TODO: Warn if a runtime package contains a runtime.json? -> We don't download them here :/
match runtimeResolution with
| Resolution.Ok runtimeResolved ->
let mapped =
runtimeResolved
|> Map.map (fun _ v -> { v with IsRuntimeDependency = true })
Map.merge (fun p1 p2 ->
if p1.Version = p2.Version then
p1
else
failwithf "same package '%A' in runtime '%A' and regular '%A' resolution with different versions" p1.Name p1.Version p2.Version) resolved mapped
|> Resolution.Ok
| _ -> resolution
| Resolution.Conflict _ -> resolution

{ ResolvedPackages = runtimeResolution
ResolvedSourceFiles = remoteFiles }

groupsToResolve
Expand Down
25 changes: 20 additions & 5 deletions src/Paket.Core/Files/LockFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ module LockFileSerializer =
{ package.Settings with FrameworkRestrictions = FrameworkRestrictionList [] }
else
package.Settings
let s = settings.ToString().ToLower()
let s =
// add "isRuntimeDependency"
match package.IsRuntimeDependency, settings.ToString().ToLower() with
| true, "" -> "isRuntimeDependency: true"
| true, s -> s + ", isRuntimeDependency: true"
| _, s -> s

if s = "" then
yield sprintf " %O %s" package.Name versionStr
Expand Down Expand Up @@ -359,7 +364,14 @@ module LockFileParser =
("framework: " + parts.[1])
else
parts.[1]
parts.[0],InstallSettings.Parse(optionsString)
let isRuntimeDependency, optionsString =
if optionsString.EndsWith ", isRuntimeDependency: true" then
true, optionsString.Substring(0, optionsString.Length - ", isRuntimeDependency: true".Length)
elif optionsString.EndsWith "isRuntimeDependency: true" then
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...


([{ GroupName = Constants.MainDependencyGroup; RepositoryType = None; RemoteUrl = None; Packages = []; SourceFiles = []; Options = InstallOptions.Default; LastWasPackage = false }], lockFileLines)
||> Seq.fold(fun state line ->
Expand Down Expand Up @@ -394,7 +406,7 @@ module LockFileParser =
| NugetPackage details ->
match currentGroup.RemoteUrl with
| Some remote ->
let package,settings = parsePackage details
let package,isRuntimeDependency,settings = parsePackage details
let parts' = package.Split ' '
let version =
if parts'.Length < 2 then
Expand All @@ -409,10 +421,13 @@ module LockFileParser =
Dependencies = Set.empty
Unlisted = false
Settings = settings
Version = SemVer.Parse version } :: currentGroup.Packages }::otherGroups
Version = SemVer.Parse version
// TODO: write stuff into the lockfile and read it here
IsRuntimeDependency = isRuntimeDependency } :: currentGroup.Packages }::otherGroups
| None -> failwith "no source has been specified."
| NugetDependency (name, v, frameworkSettings) ->
let version,settings = parsePackage v
let version,isRuntimeDependency,settings = parsePackage v
assert (not isRuntimeDependency)
if currentGroup.LastWasPackage then
match currentGroup.Packages with
| currentPackage :: otherPackages ->
Expand Down
1 change: 0 additions & 1 deletion src/Paket.Core/Files/ProjectFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,6 @@ module ProjectFile =
|> List.sortBy (fun libFolder -> libFolder.Path)
|> List.collect (fun libFolder ->
match libFolder with
//| x when (match x.Targets with | [SinglePlatform(Runtimes(_))] -> true | _ -> false) -> [] // TODO: Add reference to custom task instead
| _ ->
match PlatformMatching.getCondition referenceCondition allTargets libFolder.Targets with
| "" -> []
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/FindOutdated.fs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ let FindOutdated strict includingPrereleases groupNameFilter environment = trial
| None -> dependenciesFile.Groups
| Some gname -> dependenciesFile.Groups |> Map.filter(fun k g -> k.ToString() = gname)

let newResolution = dependenciesFile.Resolve(force, getSha1, getVersionsF, NuGetV2.GetPackageDetails alternativeProjectRoot root true, checkedDepsGroups, PackageResolver.UpdateMode.UpdateAll)
let newResolution = dependenciesFile.Resolve(force, getSha1, getVersionsF, NuGetV2.GetPackageDetails alternativeProjectRoot root true, RuntimeGraph.getRuntimeGraphFromNugetCache root, checkedDepsGroups, PackageResolver.UpdateMode.UpdateAll)

let checkedLockGroups =
match groupNameFilter with
Expand Down
17 changes: 0 additions & 17 deletions src/Paket.Core/FrameworkHandling.fs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ type FrameworkIdentifier =
| MonoTouch
| MonoMac
| Native of BuildMode * Platform
//| Runtimes of string
| XamariniOS
| XamarinMac
| Windows of string
Expand All @@ -228,7 +227,6 @@ type FrameworkIdentifier =
| MonoTouch -> "monotouch"
| MonoMac -> "monomac"
| Native(_) -> "native"
//| Runtimes(_) -> "runtimes"
| XamariniOS -> "xamarinios"
| UAP v -> "uap" + v.ShortString()
| XamarinMac -> "xamarinmac"
Expand All @@ -245,7 +243,6 @@ type FrameworkIdentifier =
| MonoTouch -> [ ]
| MonoMac -> [ ]
| Native(_) -> [ ]
//| Runtimes(_) -> [ ]
| XamariniOS -> [ ]
| XamarinMac -> [ ]
| UAP UAPVersion.V10 -> [ ]
Expand Down Expand Up @@ -307,7 +304,6 @@ type FrameworkIdentifier =
| DNXCore _, DNXCore _ -> true
| MonoAndroid _, MonoAndroid _ -> true
| MonoMac _, MonoMac _ -> true
//| Runtimes _, Runtimes _ -> true
| MonoTouch _, MonoTouch _ -> true
| Windows _, Windows _ -> true
| WindowsPhoneApp _, WindowsPhoneApp _ -> true
Expand Down Expand Up @@ -368,7 +364,6 @@ module FrameworkDetection =
// Each time the parsing is changed, NuGetPackageCache.CurrentCacheVersion should be bumped.
let result =
match path with
//| x when x.StartsWith "runtimes/" -> Some(Runtimes(x.Substring(9)))
| "net10" | "net1" | "10" -> Some (DotNetFramework FrameworkVersion.V1)
| "net11" | "11" -> Some (DotNetFramework FrameworkVersion.V1_1)
| "net20" | "net2" | "net" | "net20-full" | "net20-client" | "20" -> Some (DotNetFramework FrameworkVersion.V2)
Expand Down Expand Up @@ -684,20 +679,8 @@ module KnownTargetProfiles =
Native(Release,X64)
Native(Release,Arm)]

//let AllRuntimes =
// [ Runtimes("win7-x64")
// Runtimes("win7-x86")
// Runtimes("win7-arm")
// Runtimes("debian-x64")
// Runtimes("aot")
// Runtimes("win")
// Runtimes("linux")
// Runtimes("unix")
// Runtimes("osx") ]

let AllProfiles =
(AllNativeProfiles |> List.map SinglePlatform) @
//(AllRuntimes |> List.map SinglePlatform) @
AllDotNetStandardProfiles @
AllDotNetProfiles

Expand Down
4 changes: 2 additions & 2 deletions src/Paket.Core/InstallModel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ module InstallModel =
getLegacyReferences target installModel
else results

let getRuntimeLibraries (target : TargetProfile) (installModel:InstallModel) =
let getRuntimeLibraries graph rid (target : TargetProfile) (installModel:InstallModel) =
getFileFolders target (installModel.RuntimeLibFolders) (function Reference.Library lib -> Some lib | _ -> None)
|> Seq.cache

Expand Down Expand Up @@ -730,7 +730,7 @@ type InstallModel with
member this.GetLibReferences target = InstallModel.getLegacyReferences target this
member this.GetLegacyReferences target = InstallModel.getLegacyReferences target this
member this.GetCompileReferences target = InstallModel.getCompileReferences target this
member this.GetRuntimeLibraries target = InstallModel.getRuntimeLibraries target this
member this.GetRuntimeLibraries graph rid target = InstallModel.getRuntimeLibraries graph rid target this

[<Obsolete("usually this should not be used, use GetLegacyReferences for the full .net and GetCompileReferences for dotnetcore")>]
member this.GetLibReferences frameworkIdentifier = InstallModel.getLegacyPlatformReferences frameworkIdentifier this
Expand Down
17 changes: 17 additions & 0 deletions src/Paket.Core/NuGetV2.fs
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,23 @@ let DownloadPackage(alternativeProjectRoot, root, (source : PackageSource), cach
elif not force && getFromCache caches then
()
else
match source with
| LocalNuGet(path,_) ->
let path = Utils.normalizeLocalPath path
let di = Utils.getDirectoryInfoForLocalNuGetFeed path alternativeProjectRoot root
let nupkg = findLocalPackage di.FullName packageName version

//caches
//|> Seq.iter (fun cache ->
// try
// CopyToCache(cache,nupkg.FullName,force)
// with
// | exn ->
// if verbose then
// traceWarnfn "Could not copy %s to cache %s%s%s" nupkg.FullName cache.Location Environment.NewLine exn.Message)

File.Copy(nupkg.FullName,targetFileName)
| _ ->
// discover the link on the fly
let downloadUrl = ref ""
try
Expand Down
Loading