Skip to content

Commit

Permalink
proper fix for fsprojects#1779
Browse files Browse the repository at this point in the history
  • Loading branch information
matthid committed Jul 10, 2016
1 parent f76cfc6 commit 83d2339
Show file tree
Hide file tree
Showing 13 changed files with 221 additions and 1 deletion.
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 @@ -52,7 +52,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
|> List.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
5 changes: 5 additions & 0 deletions tests/Paket.Tests/InstallModel/Penalty/PenaltySpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ module ``ProfileAnalyzer tests`` =

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)))
Expand Down
39 changes: 39 additions & 0 deletions tests/Paket.Tests/InstallModel/ProcessingSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,45 @@ let ``should filter properly when portables are available``() =
|> Seq.toList
|> shouldEqual [ ]

[<Test>]
let ``should keep net20 if nothing better is available``() =
let model =
InstallModel.CreateFromLibs
(PackageName "EPPlus", SemVer.Parse "4.0.5",
[ ],
[ @"..\EPPlus\lib\net20\EPPlus.dll" ], [], [], Nuspec.All)

let filteredModel =
model.ApplyFrameworkRestrictions ( [ FrameworkRestriction.Exactly (FrameworkIdentifier.DotNetFramework FrameworkVersion.V4_6_1) ] )

filteredModel.GetLibReferences(SinglePlatform(DotNetFramework(FrameworkVersion.V4_6_1)))
|> Seq.toList
|> shouldEqual [ @"..\EPPlus\lib\net20\EPPlus.dll" ]

filteredModel.GetLibReferences(SinglePlatform(DotNetFramework(FrameworkVersion.V4)))
|> Seq.toList
|> shouldEqual [ ]

[<Test>]
let ``prefer net20 over empty folder``() =
let model =
InstallModel.CreateFromLibs
(PackageName "EPPlus", SemVer.Parse "4.0.5",
[ ],
[ @"..\EPPlus\lib\readme.txt"
@"..\EPPlus\lib\net20\EPPlus.dll" ], [], [], Nuspec.All)

let filteredModel =
model.ApplyFrameworkRestrictions ( [ FrameworkRestriction.Exactly (FrameworkIdentifier.DotNetFramework FrameworkVersion.V4_6_1) ] )

filteredModel.GetLibReferences(SinglePlatform(DotNetFramework(FrameworkVersion.V4_6_1)))
|> Seq.toList
|> shouldEqual [ @"..\EPPlus\lib\net20\EPPlus.dll" ]

filteredModel.GetLibReferences(SinglePlatform(DotNetFramework(FrameworkVersion.V4)))
|> Seq.toList
|> shouldEqual [ ]

[<Test>]
let ``should understand xamarinios``() =
let model = emptymodel.ApplyFrameworkRestrictions ([FrameworkRestriction.Exactly (XamariniOS)])
Expand Down

0 comments on commit 83d2339

Please sign in to comment.