Skip to content

Commit

Permalink
Runtime deps are copied based on TargetFramework - fixes #1751
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jun 23, 2016
1 parent a52b0e8 commit 521ccf3
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 27 deletions.
21 changes: 3 additions & 18 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,21 @@
#### 3.1.9 - 22.06.2016
#### 3.2.0-alpha001 - 23.06.2016
* BUGFIX: Runtime deps are copied based on TargetFramework - https://github.com/fsprojects/Paket/issues/1751
* BUGFIX: Do not take over control over manual nodes - https://github.com/fsprojects/Paket/issues/1746

#### 3.1.8 - 21.06.2016
* BUGFIX: Better error message when log file is missing - https://github.com/fsprojects/Paket/issues/1743

#### 3.1.7 - 20.06.2016
* BUGFIX: Create folder if needed during package extraction - https://github.com/fsprojects/Paket/issues/1741

#### 3.1.6 - 19.06.2016
* BUGFIX: Simplify works with auto-detected target frameworks - https://github.com/fsprojects/Paket/pull/1740

#### 3.1.5 - 18.06.2016
* BUGFIX: Make sure Guid in project reference is parsed well - https://github.com/fsprojects/Paket/pull/1738

#### 3.1.4 - 17.06.2016
* BUGFIX: Added a username and password option scripting - https://github.com/fsprojects/Paket/pull/1736

#### 3.1.3 - 16.06.2016
* BUGFIX: Trailing slash will be removed from credentials - https://github.com/fsprojects/Paket/pull/1735

#### 3.1.2 - 16.06.2016
* COSMETICS: Add condition to AfterBuild target to unbreak nCrunch - https://github.com/fsprojects/Paket/pull/1734

#### 3.1.1 - 16.06.2016
* BUGFIX: Ignore case in aliases dll names - https://github.com/fsprojects/Paket/pull/1733

#### 3.1.0 - 16.06.2016
* Paket pack doesn't allow empty string as authors and description metadata - https://github.com/fsprojects/Paket/pull/1728
* Made Name and Guid in ProjectRefrence optional - https://github.com/fsprojects/Paket/issues/1729
* BUGFIX: Prerelease version range are working with ~> again
* BUGFIX: Filter empty When conditions - https://github.com/fsprojects/Paket/issues/1727
* BUGFIX: Do not garbage collect pacakges with version in path
* BUGFIX: Do not garbage collect packages with version in path

#### 3.0.0 - 15.06.2016
* Allow to reference git repositories - http://fsprojects.github.io/Paket/git-dependencies.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<Import Project="$(FSharpTargetsPath)" />
<UsingTask TaskName="CopyRuntimeDependencies" AssemblyFile="..\.paket\paket.exe" />
<Target Name="AfterBuild" Condition="Exists('..\.paket\paket.exe')">
<CopyRuntimeDependencies OutputPath="$(OutputPath)" ProjectsWithRuntimeLibs="System.Collections;System.Diagnostics.Debug;System.Globalization;System.IO;System.Private.Uri;System.Reflection;System.Reflection.Extensions;System.Reflection.Primitives;System.Resources.ResourceManager;System.Runtime;System.Runtime.Extensions;System.Runtime.InteropServices;System.Text.Encoding;System.Text.Encoding.Extensions;System.Threading;System.Threading.Tasks" />
<CopyRuntimeDependencies OutputPath="$(OutDir)" TargetFramework="$(TargetFrameworkIdentifier) - $(TargetFrameworkVersion)" ProjectsWithRuntimeLibs="System.Collections;System.Diagnostics.Debug;System.Globalization;System.IO;System.Private.Uri;System.Reflection;System.Reflection.Extensions;System.Reflection.Primitives;System.Resources.ResourceManager;System.Runtime;System.Runtime.Extensions;System.Runtime.InteropServices;System.Text.Encoding;System.Text.Encoding.Extensions;System.Threading;System.Threading.Tasks" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -52,7 +52,7 @@
<Import Project="$(FSharpTargetsPath)" />
<UsingTask TaskName="CopyRuntimeDependencies" AssemblyFile="..\.paket\paket.exe" />
<Target Name="AfterBuild" Condition="Exists('..\.paket\paket.exe')">
<CopyRuntimeDependencies OutputPath="$(OutputPath)" ProjectsWithRuntimeLibs="System.Collections;System.Diagnostics.Debug;System.Globalization;System.IO;System.Private.Uri;System.Reflection;System.Reflection.Primitives;System.Resources.ResourceManager;System.Runtime;System.Runtime.Extensions;System.Text.Encoding;System.Text.Encoding.Extensions;System.Threading;System.Threading.Tasks" />
<CopyRuntimeDependencies OutputPath="$(OutDir)" TargetFramework="$(TargetFrameworkIdentifier) - $(TargetFrameworkVersion)" ProjectsWithRuntimeLibs="System.Collections;System.Diagnostics.Debug;System.Globalization;System.IO;System.Private.Uri;System.Reflection;System.Reflection.Primitives;System.Resources.ResourceManager;System.Runtime;System.Runtime.Extensions;System.Text.Encoding;System.Text.Encoding.Extensions;System.Threading;System.Threading.Tasks" />
</Target>
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
Expand Down
5 changes: 3 additions & 2 deletions src/Paket.Core/ProjectFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ module ProjectFile =
if projectModel.GetLibReferences targetFramework |> Seq.isEmpty then
let libReferences =
projectModel.GetLibReferencesLazy |> force
|> Seq.filter (fun l -> match l with | Reference.Library _ -> true | _ -> false)
|> Seq.filter (fun l -> match l with | Reference.Library _ -> true | _ -> false)

if not (Seq.isEmpty libReferences) then
traceWarnfn "Package %O contains libraries, but not for the selected TargetFramework %O in project %s."
Expand Down Expand Up @@ -994,7 +994,8 @@ module ProjectFile =

let runtimeDependenciesNode =
createNode "CopyRuntimeDependencies" project
|> addAttribute "OutputPath" "$(OutputPath)"
|> addAttribute "OutputPath" "$(OutDir)"
|> addAttribute "TargetFramework" "$(TargetFrameworkIdentifier) - $(TargetFrameworkVersion)"
|> addAttribute "ProjectsWithRuntimeLibs" allPackages

let j = ref 0
Expand Down
4 changes: 2 additions & 2 deletions src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
<StartWorkingDirectory>D:\code\PaketKopie</StartWorkingDirectory>
<StartArguments>update -f</StartArguments>
<StartWorkingDirectory>D:\code\Paket\integrationtests\scenarios\i001117-aws\temp</StartWorkingDirectory>
<StartArguments>install</StartArguments>
<StartWorkingDirectory>D:\code\Paket\integrationtests\scenarios\i001746-hard-legacy\temp</StartWorkingDirectory>
<StartArguments>update</StartArguments>
<StartWorkingDirectory>D:\code\paket3dotnetcoreissue</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
Expand Down
37 changes: 35 additions & 2 deletions src/Paket/PlatformTask.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ open Microsoft.Build.Utilities
open Microsoft.Build.Framework
open Paket
open Paket.Domain
open Paket.Requirements

type CopyRuntimeDependencies() =
inherit Task()

let mutable outputPath = ""
let mutable targetFramework = ""
let mutable projectFile = ""
let mutable projectsWithRuntimeLibs = ""

Expand All @@ -28,6 +30,10 @@ type CopyRuntimeDependencies() =
with get() = outputPath
and set(v) = outputPath <- v

member this.TargetFramework
with get() = targetFramework
and set(v) = targetFramework <- v

override this.Execute() =
let resultCode =
try
Expand All @@ -38,6 +44,8 @@ type CopyRuntimeDependencies() =
else ["linux"; "debian-x64"; "unix"]

base.Log.LogMessage(MessageImportance.Normal, "Detected runtimes: {0}", sprintf "%A" currentRuntimes)
base.Log.LogMessage(MessageImportance.Normal, "Target framework: {0}", targetFramework)

let currentRuntimes = currentRuntimes |> Set.ofList
let projectFile = FileInfo(if String.IsNullOrWhiteSpace this.ProjectFile then this.BuildEngine.ProjectFileOfTaskNode else this.ProjectFile)

Expand All @@ -59,15 +67,40 @@ type CopyRuntimeDependencies() =
let dependenciesFile = dependencies.GetDependenciesFile()

let root = Path.GetDirectoryName lockFile.FileName

let packagesToInstall =
if not <| String.IsNullOrEmpty targetFramework then
let s = targetFramework.Split([|" - "|],StringSplitOptions.None)
let restriction =
match FrameworkDetection.Extract(s.[0] + s.[1].Replace("v","")) with
| None -> SinglePlatform(DotNetFramework FrameworkVersion.V4)
| Some x -> SinglePlatform(x)

packagesToInstall
|> Array.filter (fun (groupName,packageName) ->
try
let g = lockFile.Groups.[groupName]
let p = g.Resolution.[packageName]
match filterRestrictions g.Options.Settings.FrameworkRestrictions p.Settings.FrameworkRestrictions with
| FrameworkRestrictionList restrictions ->
isTargetMatchingRestrictions(restrictions,restriction)
| _ -> true
with
| _ -> true)
else
packagesToInstall

let model = InstallProcess.CreateModel(root, false, dependenciesFile, lockFile, Set.ofSeq packagesToInstall, Map.empty) |> Map.ofArray

let projectDir = FileInfo(this.BuildEngine.ProjectFileOfTaskNode).Directory

for group,packageName in packagesToInstall do
match model |> Map.tryFind (group,packageName) with
| None -> failwithf "Package %O %O was not found in the install model" group packageName
| Some (package,model) ->
| Some (package,projectModel) ->

let files =
model.ReferenceFileFolders
projectModel.ReferenceFileFolders
|> List.choose (fun lib ->
match lib with
| x when (match x.Targets with | [SinglePlatform(Runtimes(x))] when currentRuntimes |> Set.contains x -> true | _ -> false) -> Some lib.Files
Expand Down

0 comments on commit 521ccf3

Please sign in to comment.