Skip to content

Commit

Permalink
proper fix for #1779
Browse files Browse the repository at this point in the history
# Conflicts:
#	tests/Paket.Tests/InstallModel/Penalty/PenaltySpecs.fs
#	tests/Paket.Tests/InstallModel/ProcessingSpecs.fs
  • Loading branch information
matthid authored and forki committed Jul 12, 2016
1 parent 02d4172 commit 73a463f
Show file tree
Hide file tree
Showing 13 changed files with 364 additions and 2 deletions.
9 changes: 9 additions & 0 deletions integrationtests/Paket.IntegrationTests/InstallSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -499,4 +499,13 @@ let ``#1746 hard should be softer``() =
let oldFile = Path.Combine(originalScenarioPath "i001746-hard-legacy","SilverlightClassLibrary1","SilverlightClassLibrary1.csprojtemplate")
let s1 = File.ReadAllText oldFile |> normalizeLineEndings
let s2 = File.ReadAllText newFile |> normalizeLineEndings
s2 |> shouldEqual s1

[<Test>]
let ``#1779 net20 only in net461``() =
install "i001779-net20-only-in-net461" |> ignore
let newFile = Path.Combine(scenarioTempPath "i001779-net20-only-in-net461","paket-net20-library-problem","paket-net20-library-problem.csproj")
let oldFile = Path.Combine(originalScenarioPath "i001779-net20-only-in-net461","paket-net20-library-problem","paket-net20-library-problem.csprojtemplate")
let s1 = File.ReadAllText oldFile |> normalizeLineEndings
let s2 = File.ReadAllText newFile |> normalizeLineEndings
s2 |> shouldEqual s1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "paket-net20-library-problem", "paket-net20-library-problem\paket-net20-library-problem.csproj", "{80463970-51EF-43F4-AEB6-39677B6C5A2B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{BF533A22-4725-4C6E-B604-371A10EC914A}"
ProjectSection(SolutionItems) = preProject
paket.dependencies = paket.dependencies
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{80463970-51EF-43F4-AEB6-39677B6C5A2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80463970-51EF-43F4-AEB6-39677B6C5A2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80463970-51EF-43F4-AEB6-39677B6C5A2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80463970-51EF-43F4-AEB6-39677B6C5A2B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace paket_net20_library_problem
{
class Program
{
static void Main(string[] args)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("paket-net20-library-problem")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("paket-net20-library-problem")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("80463970-51ef-43f4-aeb6-39677b6c5a2b")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?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>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{80463970-51EF-43F4-AEB6-39677B6C5A2B}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>paket_net20_library_problem</RootNamespace>
<AssemblyName>paket-net20-library-problem</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="paket.references" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="EPPlus">
<HintPath>..\packages\EPPlus\lib\net20\EPPlus.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
EPPlus
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
framework: net461
source https://www.nuget.org/api/v2/
nuget EPPlus ~> 4.0.5
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FRAMEWORK: NET461
NUGET
remote: https://www.nuget.org/api/v2
EPPlus (4.0.5)
2 changes: 1 addition & 1 deletion src/Paket.Core/PlatformMatching.fs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ let getPathPenalty =
if String.IsNullOrWhiteSpace path then
match platform with
| Native(_) -> MaxPenalty // an empty path is considered incompatible with native targets
| _ -> 10 // an empty path is considered compatible with every .NET target, but with a high penalty so explicit paths are preferred
| _ -> 500 // an empty path is considered compatible with every .NET target, but with a high penalty so explicit paths are preferred
else
extractPlatforms path
|> Array.map (fun target -> getPlatformPenalty(platform,target))
Expand Down
2 changes: 2 additions & 0 deletions src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
<StartAction>Project</StartAction>
<StartProgram>paket.exe</StartProgram>
<StartAction>Project</StartAction>
<StartArguments>install -v</StartArguments>
<StartWorkingDirectory>C:\PROJ\Paket\integrationtests\scenarios\i001779-net20-only-in-net461\temp</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down
122 changes: 122 additions & 0 deletions tests/Paket.Tests/InstallModel/Penalty/PenaltySpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,125 @@ module ``Given a list of paths`` =
yield! item.Value
}
flattend |> shouldNotContain (KnownTargetProfiles.FindPortableProfile "Profile41")

module ``General Penalty checks`` =

[<Test>]
let ``prefer net20 over emtpy folder``()=
Paket.PlatformMatching.findBestMatch ([""; "net20"], SinglePlatform(DotNetFramework(FrameworkVersion.V4_6_1)))
|> shouldEqual (Some "net20")

[<Test>]
let ``best match for DotNet Standard 1.0``()=
Paket.PlatformMatching.findBestMatch (["net20"; "net40"; "net45"; "net451"], SinglePlatform(DotNetStandard(DotNetStandardVersion.V1_0)))
|> shouldEqual (None)


[<Test>]
let ``best match for DotNet Standard 1.1``()=
Paket.PlatformMatching.findBestMatch (["net20"; "net40"; "net45"; "net451"], SinglePlatform(DotNetStandard(DotNetStandardVersion.V1_1)))
|> shouldEqual (None)

[<Test>]
let ``best match for DotNet Standard 1.5``()=
Paket.PlatformMatching.findBestMatch (["net20"; "net40"; "net45"; "net451"], SinglePlatform(DotNetStandard(DotNetStandardVersion.V1_5)))
|> shouldEqual (None)

[<Test>]
let ``best match for net45``()=
Paket.PlatformMatching.findBestMatch
(["netstandard10"; "netstandard11"; "netstandard12"; "netstandard13"; "netstandard14"; "netstandard15"; "netstandard16"],
SinglePlatform(DotNetFramework(FrameworkVersion.V4_5)))
|> shouldEqual (Some ("netstandard11"))


[<Test>]
let ``best match for netstandard in portable``()=
Paket.PlatformMatching.findBestMatch
(["portable-netcore451+wpa81"],
SinglePlatform(DotNetStandard(DotNetStandardVersion.V1_1)))
|> shouldEqual (None)

Paket.PlatformMatching.findBestMatch
(["portable-netcore451+wpa81"],
SinglePlatform(DotNetStandard(DotNetStandardVersion.V1_2)))
|> shouldEqual (Some ("portable-netcore451+wpa81"))

Paket.PlatformMatching.findBestMatch
(["portable-netcore451+wpa81"],
SinglePlatform(DotNetStandard(DotNetStandardVersion.V1_3)))
|> shouldEqual (Some ("portable-netcore451+wpa81"))

Paket.PlatformMatching.findBestMatch
(["portable-netcore451+wpa81"],
SinglePlatform(DotNetStandard(DotNetStandardVersion.V1_4)))
|> shouldEqual (Some ("portable-netcore451+wpa81"))

Paket.PlatformMatching.findBestMatch
(["portable-netcore451+wpa81"],
SinglePlatform(DotNetStandard(DotNetStandardVersion.V1_5)))
|> shouldEqual (Some ("portable-netcore451+wpa81"))

Paket.PlatformMatching.findBestMatch
(["portable-netcore451+wpa81"],
SinglePlatform(DotNetStandard(DotNetStandardVersion.V1_6)))
|> shouldEqual (Some ("portable-netcore451+wpa81"))

[<Test>]
let ``best match for netstandard, netstandard is preferred``()=
Paket.PlatformMatching.findBestMatch
(["portable-win81+wpa81"; "netstandard1.3"],
SinglePlatform(DotNetStandard(DotNetStandardVersion.V1_2)))
|> shouldEqual (Some ("portable-win81+wpa81"))

Paket.PlatformMatching.findBestMatch
(["portable-win81+wpa81"; "netstandard1.3"],
SinglePlatform(DotNetStandard(DotNetStandardVersion.V1_3)))
|> shouldEqual (Some ("netstandard1.3"))

Paket.PlatformMatching.findBestMatch
(["portable-win81+wpa81"; "netstandard1.3"],
SinglePlatform(DotNetStandard(DotNetStandardVersion.V1_4)))
|> shouldEqual (Some ("netstandard1.3"))

[<Test>]
let ``best match for netstandard, use possible.``()=
Paket.PlatformMatching.findBestMatch
// Profile31 (supports netstandard1.0), Profile32 (supports netstandard1.2)
(["portable-netcore451+wp81"; "portable-netcore451+wpa81"],
SinglePlatform(DotNetStandard(DotNetStandardVersion.V1_0)))
|> shouldEqual (Some "portable-netcore451+wp81")

Paket.PlatformMatching.findBestMatch
// Profile31 (supports netstandard1.0), Profile32 (supports netstandard1.2)
(["portable-netcore451+wp81"; "portable-netcore451+wpa81"],
SinglePlatform(DotNetStandard(DotNetStandardVersion.V1_2)))
|> shouldEqual (Some "portable-netcore451+wpa81")

Paket.PlatformMatching.findBestMatch
// Profile31 (supports netstandard1.0), Profile32 (supports netstandard1.2)
(["portable-netcore451+wp81"; "portable-netcore451+wpa81"],
SinglePlatform(DotNetStandard(DotNetStandardVersion.V1_4)))
|> shouldEqual (Some "portable-netcore451+wpa81")

[<Test>]
let ``make sure not all portable profiles match``()=
// Not all portable profiles have a match.
Paket.PlatformMatching.findBestMatch
(["portable-net403+sl5+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1"],
SinglePlatform(DotNetStandard(DotNetStandardVersion.V1_0)))
|> shouldEqual (None)

[<Test>]
let ``best match for net451``()=
Paket.PlatformMatching.findBestMatch
(["netstandard10"; "netstandard11"; "netstandard12"; "netstandard13"; "netstandard14"; "netstandard15"; "netstandard16"],
SinglePlatform(DotNetFramework(FrameworkVersion.V4_5_1)))
|> shouldEqual (Some ("netstandard12"))

[<Test>]
let ``best match for net463``()=
Paket.PlatformMatching.findBestMatch
(["netstandard10"; "netstandard11"; "netstandard12"; "netstandard13"; "netstandard14"; "netstandard15"; "netstandard16"],
SinglePlatform(DotNetFramework(FrameworkVersion.V4_6_3)))
|> shouldEqual (Some ("netstandard16"))
Loading

0 comments on commit 73a463f

Please sign in to comment.