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

WIP: Fix dotnetcore #2252

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

<Choose>
<When Condition="'$(Configuration)|$(Platform)'=='Debug|arm'">
<ItemGroup>
Expand All @@ -125,19 +124,28 @@
</NativeReference>
</ItemGroup>
</When>
<When Condition="'$(Configuration)|$(Platform)'=='Release|arm'">
<When Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ItemGroup>
<NativeReference Include="cpprest120_app_2_7">
<HintPath>..\packages\cpprestsdk.v120.winapp.msvcstl.dyn.rt-dyn\lib\native\v120\winapp\msvcstl\dyn\rt-dyn\arm\Release\cpprest120_app_2_7.dll</HintPath>
<NativeReference Include="cpprest120d_app_2_7">
<HintPath>..\packages\cpprestsdk.v120.winapp.msvcstl.dyn.rt-dyn\lib\native\v120\winapp\msvcstl\dyn\rt-dyn\x64\Debug\cpprest120d_app_2_7.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</NativeReference>
</ItemGroup>
</When>
<When Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<When Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ItemGroup>
<NativeReference Include="cpprest120d_app_2_7">
<HintPath>..\packages\cpprestsdk.v120.winapp.msvcstl.dyn.rt-dyn\lib\native\v120\winapp\msvcstl\dyn\rt-dyn\x64\Debug\cpprest120d_app_2_7.dll</HintPath>
<HintPath>..\packages\cpprestsdk.v120.winapp.msvcstl.dyn.rt-dyn\lib\native\v120\winapp\msvcstl\dyn\rt-dyn\x86\Debug\cpprest120d_app_2_7.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</NativeReference>
</ItemGroup>
</When>
<When Condition="'$(Configuration)|$(Platform)'=='Release|arm'">
<ItemGroup>
<NativeReference Include="cpprest120_app_2_7">
<HintPath>..\packages\cpprestsdk.v120.winapp.msvcstl.dyn.rt-dyn\lib\native\v120\winapp\msvcstl\dyn\rt-dyn\arm\Release\cpprest120_app_2_7.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</NativeReference>
Expand Down Expand Up @@ -172,6 +180,15 @@
</NativeReference>
</ItemGroup>
</When>
<When Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ItemGroup>
<NativeReference Include="cpprest120d_2_7">
<HintPath>..\packages\cpprestsdk.v120.windesktop.msvcstl.dyn.rt-dyn\lib\native\v120\windesktop\msvcstl\dyn\rt-dyn\x86\Debug\cpprest120d_2_7.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</NativeReference>
</ItemGroup>
</When>
<When Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ItemGroup>
<NativeReference Include="cpprest120_2_7">
Expand Down Expand Up @@ -201,6 +218,15 @@
</NativeReference>
</ItemGroup>
</When>
<When Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ItemGroup>
<NativeReference Include="cpprest120d_wp81_2_7">
<HintPath>..\packages\cpprestsdk.v120.winphone.msvcstl.dyn.rt-dyn\lib\native\v120\winphone\msvcstl\dyn\rt-dyn\x86\Debug\cpprest120d_wp81_2_7.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</NativeReference>
</ItemGroup>
</When>
<When Condition="'$(Configuration)|$(Platform)'=='Release|arm'">
<ItemGroup>
<NativeReference Include="cpprest120_wp81_2_7">
Expand Down Expand Up @@ -230,6 +256,15 @@
</NativeReference>
</ItemGroup>
</When>
<When Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ItemGroup>
<NativeReference Include="cpprest120d_wps81_2_7">
<HintPath>..\packages\cpprestsdk.v120.winphonesl.msvcstl.dyn.rt-dyn\lib\native\v120\winphonesl\msvcstl\dyn\rt-dyn\x86\Debug\cpprest120d_wps81_2_7.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</NativeReference>
</ItemGroup>
</When>
<When Condition="'$(Configuration)|$(Platform)'=='Release|arm'">
<ItemGroup>
<NativeReference Include="cpprest120_wps81_2_7">
Expand Down Expand Up @@ -259,6 +294,15 @@
</NativeReference>
</ItemGroup>
</When>
<When Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ItemGroup>
<NativeReference Include="cpprest120d_xp_2_7">
<HintPath>..\packages\cpprestsdk.v120.winxp.msvcstl.dyn.rt-dyn\lib\native\v120\winxp\msvcstl\dyn\rt-dyn\x86\Debug\cpprest120d_xp_2_7.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</NativeReference>
</ItemGroup>
</When>
<When Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ItemGroup>
<NativeReference Include="cpprest120_xp_2_7">
Expand Down Expand Up @@ -288,19 +332,28 @@
</NativeReference>
</ItemGroup>
</When>
<When Condition="'$(Configuration)|$(Platform)'=='Release|arm'">
<When Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ItemGroup>
<NativeReference Include="cpprest140_uwp_2_7">
<HintPath>..\packages\cpprestsdk.v140.winapp.msvcstl.dyn.rt-dyn\lib\native\v140\winapp\msvcstl\dyn\rt-dyn\arm\Release\cpprest140_uwp_2_7.dll</HintPath>
<NativeReference Include="cpprest140d_uwp_2_7">
<HintPath>..\packages\cpprestsdk.v140.winapp.msvcstl.dyn.rt-dyn\lib\native\v140\winapp\msvcstl\dyn\rt-dyn\x64\Debug\cpprest140d_uwp_2_7.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</NativeReference>
</ItemGroup>
</When>
<When Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<When Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ItemGroup>
<NativeReference Include="cpprest140d_uwp_2_7">
<HintPath>..\packages\cpprestsdk.v140.winapp.msvcstl.dyn.rt-dyn\lib\native\v140\winapp\msvcstl\dyn\rt-dyn\x64\Debug\cpprest140d_uwp_2_7.dll</HintPath>
<HintPath>..\packages\cpprestsdk.v140.winapp.msvcstl.dyn.rt-dyn\lib\native\v140\winapp\msvcstl\dyn\rt-dyn\x86\Debug\cpprest140d_uwp_2_7.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</NativeReference>
</ItemGroup>
</When>
<When Condition="'$(Configuration)|$(Platform)'=='Release|arm'">
<ItemGroup>
<NativeReference Include="cpprest140_uwp_2_7">
<HintPath>..\packages\cpprestsdk.v140.winapp.msvcstl.dyn.rt-dyn\lib\native\v140\winapp\msvcstl\dyn\rt-dyn\arm\Release\cpprest140_uwp_2_7.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</NativeReference>
Expand Down Expand Up @@ -335,6 +388,15 @@
</NativeReference>
</ItemGroup>
</When>
<When Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ItemGroup>
<NativeReference Include="cpprest140d_2_7">
<HintPath>..\packages\cpprestsdk.v140.windesktop.msvcstl.dyn.rt-dyn\lib\native\v140\windesktop\msvcstl\dyn\rt-dyn\x86\Debug\cpprest140d_2_7.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</NativeReference>
</ItemGroup>
</When>
<When Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ItemGroup>
<NativeReference Include="cpprest140_2_7">
Expand Down
27 changes: 18 additions & 9 deletions src/Paket.Core/Files/ProjectFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -744,12 +744,20 @@ module ProjectFile =
model.GetReferenceFolders()
|> List.map (fun lib -> lib.Targets)

// Just in case anyone wants to compile FOR netcore in the old format...
// I don't think there is anyone actually using this part, but it's there for backwards compat.
let netCoreRestricted =
model.ApplyFrameworkRestrictions
[ FrameworkRestriction.AtLeast (FrameworkIdentifier.DotNetStandard DotNetStandardVersion.V1_0);
FrameworkRestriction.AtLeast (FrameworkIdentifier.DotNetCore DotNetCoreVersion.V1_0) ]

// handle legacy conditions
let conditions =
model.GetReferenceFolders()
|> List.sortBy (fun libFolder -> libFolder.Name)
|> List.collect (fun libFolder ->
((model.GetReferenceFolders() |> List.sortBy (fun libFolder -> libFolder.Path)) @
netCoreRestricted.CompileRefFolders |> 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
//| 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 Expand Up @@ -788,16 +796,17 @@ module ProjectFile =
[lowerCondition,createItemGroup !assemblyTargets frameworkAssemblies,true
condition,createItemGroup libFolder.Targets rest,false]
)

// global targets are targets, that are either directly in the /build folder,
// or, if there is a framework-restriction, specific to the framework(s).
// (ref https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package#including-msbuild-props-and-targets-in-a-package).
let globalTargets, frameworkSpecificTargets =
if not importTargets then List.empty, List.empty else
let sortedTargets = model.TargetsFileFolders |> List.sortBy (fun lib -> lib.Name)
sortedTargets
|> List.partition (fun lib -> allTargetProfiles = set lib.Targets )

let sortedTargets = model.TargetsFileFolders |> List.sortBy (fun lib -> lib.Path)
//sortedTargets
//|> List.partition (fun lib -> allTargetProfiles = set lib.Targets )
([] : LibFolder list), sortedTargets
Copy link
Member Author

Choose a reason for hiding this comment

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

This seems to be some code-path to "simplify" the generated project file. However it seems like it was never actually used.
After removing runtime this seems to work again (and breaks some tests).

Should we get rid of this simplification (as it was never used) or should I update the tests?


let frameworkSpecificTargetsFileConditions =
frameworkSpecificTargets
|> List.map (fun lib -> PlatformMatching.getCondition referenceCondition allTargets lib.Targets,createPropertyGroup lib.Files.References)
Expand Down
107 changes: 68 additions & 39 deletions src/Paket.Core/FrameworkHandling.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

open System.IO
open System
open System.Diagnostics

[<RequireQualifiedAccess>]
/// The Framework version.
Expand Down Expand Up @@ -142,6 +143,33 @@ module KnownAliases =
" ", "" ]
|> List.map (fun (p,r) -> p.ToLower(),r.ToLower())

type BuildMode =
| Debug
| Release
| NoBuildMode
| UnknownBuildMode of string
member x.AsString =
match x with
| Debug -> "Debug"
| Release -> "Release"
| NoBuildMode -> ""
| UnknownBuildMode s -> s
override x.ToString() = x.AsString

type Platform =
| Arm
| X64
| Win32
| NoPlatform
| UnknownPlatform of string
member x.AsString =
match x with
| Arm -> "arm"
| X64 -> "x64"
| Win32 -> "Win32"
| NoPlatform -> ""
| UnknownPlatform s -> s
override x.ToString() = x.AsString

/// Framework Identifier type.
// Each time a new version is added NuGetPackageCache.CurrentCacheVersion should be bumped.
Expand All @@ -155,8 +183,8 @@ type FrameworkIdentifier =
| MonoAndroid
| MonoTouch
| MonoMac
| Native of string * string
| Runtimes of string
| Native of BuildMode * Platform
//| Runtimes of string
| XamariniOS
| XamarinMac
| Windows of string
Expand All @@ -176,7 +204,7 @@ type FrameworkIdentifier =
| MonoTouch -> "monotouch"
| MonoMac -> "monomac"
| Native(_) -> "native"
| Runtimes(_) -> "runtimes"
//| Runtimes(_) -> "runtimes"
| XamariniOS -> "xamarinios"
| UAP v -> "uap" + v.ShortString()
| XamarinMac -> "xamarinmac"
Expand All @@ -193,7 +221,7 @@ type FrameworkIdentifier =
| MonoTouch -> [ ]
| MonoMac -> [ ]
| Native(_) -> [ ]
| Runtimes(_) -> [ ]
//| Runtimes(_) -> [ ]
| XamariniOS -> [ ]
| XamarinMac -> [ ]
| UAP UAPVersion.V10 -> [ ]
Expand Down Expand Up @@ -253,7 +281,7 @@ type FrameworkIdentifier =
| DNXCore _, DNXCore _ -> true
| MonoAndroid _, MonoAndroid _ -> true
| MonoMac _, MonoMac _ -> true
| Runtimes _, Runtimes _ -> true
//| Runtimes _, Runtimes _ -> true
| MonoTouch _, MonoTouch _ -> true
| Windows _, Windows _ -> true
| WindowsPhoneApp _, WindowsPhoneApp _ -> true
Expand Down Expand Up @@ -314,7 +342,7 @@ 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)))
//| 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 All @@ -336,15 +364,15 @@ module FrameworkDetection =
| "monomac" | "monomac10" | "monomac1" -> Some MonoMac
| "xamarinios" | "xamarinios10" | "xamarinios1" | "xamarin.ios10" -> Some XamariniOS
| "xamarinmac" | "xamarinmac20" | "xamarin.mac20" -> Some XamarinMac
| "native/x86/debug" -> Some(Native("Debug","Win32"))
| "native/x64/debug" -> Some(Native("Debug","x64"))
| "native/arm/debug" -> Some(Native("Debug","arm"))
| "native/x86/release" -> Some(Native("Release","Win32"))
| "native/x64/release" -> Some(Native("Release","x64"))
| "native/arm/release" -> Some(Native("Release","arm"))
| "native/address-model-32" -> Some(Native("","Win32"))
| "native/address-model-64" -> Some(Native("","x64"))
| "native" -> Some(Native("",""))
| "native/x86/debug" -> Some(Native(Debug,Win32))
| "native/x64/debug" -> Some(Native(Debug,X64))
| "native/arm/debug" -> Some(Native(Debug,Arm))
| "native/x86/release" -> Some(Native(Release,Win32))
| "native/x64/release" -> Some(Native(Release,X64))
| "native/arm/release" -> Some(Native(Release,Arm))
| "native/address-model-32" -> Some(Native(NoBuildMode,Win32))
| "native/address-model-64" -> Some(Native(NoBuildMode,X64))
| "native" -> Some(Native(NoBuildMode,NoPlatform))
| "sl" | "sl3" | "sl30" -> Some (Silverlight "v3.0")
| "sl4" | "sl40" -> Some (Silverlight "v4.0")
| "sl5" | "sl50" -> Some (Silverlight "v5.0")
Expand Down Expand Up @@ -609,30 +637,31 @@ module KnownTargetProfiles =
DotNetCoreProfiles

let AllNativeProfiles =
[ Native("","")
Native("","Win32")
Native("","x64")
Native("Debug","Win32")
Native("Debug","arm")
Native("Debug","x64")
Native("Release","Win32")
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) @
[ Native(NoBuildMode,NoPlatform)
Native(NoBuildMode,Win32)
Native(NoBuildMode,X64)
Native(NoBuildMode,Arm)
Native(Debug,Win32)
Native(Debug,Arm)
Native(Debug,X64)
Native(Release,Win32)
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