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

Show message if a dependency is installed for wrong target framework … #1445

Merged
merged 1 commit into from
Jan 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 5 additions & 1 deletion integrationtests/Paket.IntegrationTests/InstallSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,12 @@ let ``#1427 won't install content when content:none``() =
let oldWeavers = Path.Combine(originalScenarioPath "i001427-content-none","MyClassLibrary","MyClassLibrary","FodyWeavers.xml")
let s1 = File.ReadAllText oldWeavers |> normalizeLineEndings
let s2 = File.ReadAllText newWeavers |> normalizeLineEndings
s1 |> shouldEqual s2 // we don not touch it
s1 |> shouldEqual s2 // we do not touch it

[<Test>]
let ``#1442 warn if install finds no libs``() =
let result = paket "install" "i001442-warn-if-empty"
result |> shouldContainText "contains libraries, but not for the selected TargetFramework"

[<Test>]
let ``#1334 without download fail``() =
Expand Down
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.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".paket", ".paket", "{673951A0-5216-4FBD-BA08-7FA057D5CC0D}"
ProjectSection(SolutionItems) = preProject
..\paket.dependencies = ..\paket.dependencies
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyClassLibrary", "MyClassLibrary\MyClassLibrary.csproj", "{CD678800-8DFC-4BB1-911A-7234F492EA29}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CD678800-8DFC-4BB1-911A-7234F492EA29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CD678800-8DFC-4BB1-911A-7234F492EA29}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CD678800-8DFC-4BB1-911A-7234F492EA29}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CD678800-8DFC-4BB1-911A-7234F492EA29}.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,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyClassLibrary
{
public class Class1
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?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>{CD678800-8DFC-4BB1-911A-7234F492EA29}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MyClassLibrary</RootNamespace>
<AssemblyName>MyClassLibrary</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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' ">
<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="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</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.5.1'">
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.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,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("MyClassLibrary")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MyClassLibrary")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[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("cd678800-8dfc-4bb1-911a-7234f492ea29")]

// 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 @@
Newtonsoft.Json framework: net451
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source https://www.nuget.org/api/v2/

nuget Newtonsoft.Json
8 changes: 6 additions & 2 deletions src/Paket.Core/InstallModel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ module InstallModel =
getFileFolders target installModel.TargetsFileFolders
(function Reference.TargetsFile targetsFile -> Some targetsFile | _ -> None)

let hasReferences (installModel:InstallModel) = List.isEmpty installModel.ReferenceFileFolders |> not

let getPlatformReferences frameworkIdentifier installModel =
getLibReferences (SinglePlatform frameworkIdentifier) installModel

Expand Down Expand Up @@ -358,7 +360,7 @@ type InstallModel with

member this.MapFolders mapfn = InstallModel.mapFolders mapfn this

member this.MapFiles mapfn = InstallModel.mapFiles mapfn this
member this.MapFiles mapfn = InstallModel.mapFiles mapfn this

member this.GetLibReferences target = InstallModel.getLibReferences target this

Expand All @@ -376,6 +378,8 @@ type InstallModel with

member this.AddLibReferences (libs, references) = InstallModel.addLibReferences libs references this

member this.HasLibReferences () = InstallModel.hasReferences this

member this.AddReferences libs = InstallModel.addLibReferences libs NuspecReferences.All this

member this.AddAnalyzerFiles analyzerFiles = InstallModel.addAnalyzerFiles analyzerFiles this
Expand All @@ -384,7 +388,7 @@ type InstallModel with

member this.AddTargetsFiles targetsFiles = InstallModel.addTargetsFiles targetsFiles this

member this.AddPackageFile (path, file, references) = InstallModel.addPackageFile path file references this
member this.AddPackageFile (path, file, references) = InstallModel.addPackageFile path file references this

member this.AddFrameworkAssemblyReference reference = InstallModel.addFrameworkAssemblyReference this reference

Expand Down
1 change: 0 additions & 1 deletion src/Paket.Core/InstallProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ let InstallIntoProjects(options : InstallerOptions, dependenciesFile, lockFile :

for project, referenceFile in projectsAndReferences do
verbosefn "Installing to %s" project.FileName

let usedPackages =
referenceFile.Groups
|> Seq.map (fun kv ->
Expand Down
31 changes: 20 additions & 11 deletions src/Paket.Core/ProjectFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,6 @@ module ProjectFile =
node.InnerText <- text
node



// let createChildNode name text project =
// project |> addChild (createNodeSet name text project)

open System.Text

let getPropertyWithDefaults propertyName defaultProperties (projectFile:ProjectFile) =
Expand Down Expand Up @@ -845,11 +840,21 @@ module ProjectFile =
while List.exists (fun x -> deleteIfEmpty x project) ["ItemGroup";"When";"Otherwise";"Choose"] do
()


let getTargetFrameworkIdentifier (project:ProjectFile) = getProperty "TargetFrameworkIdentifier" project

let getTargetFrameworkProfile (project:ProjectFile) = getProperty "TargetFrameworkProfile" project

let updateReferences
(completeModel: Map<GroupName*PackageName,_*InstallModel>)
(usedPackages : Map<GroupName*PackageName,_*InstallSettings>) hard (project:ProjectFile) =
removePaketNodes project


let targetFramework =
match getProperty "TargetFrameworkVersion" project with
| None -> None
| Some v -> FrameworkDetection.Extract(v.Replace("v","net"))

completeModel
|> Seq.filter (fun kv -> usedPackages.ContainsKey kv.Key)
|> Seq.map (fun kv ->
Expand All @@ -860,6 +865,14 @@ module ProjectFile =
(snd kv.Value)
.ApplyFrameworkRestrictions(installSettings.FrameworkRestrictions)
.RemoveIfCompletelyEmpty()

match targetFramework with
| Some targetFramework ->
if projectModel.GetLibReferences targetFramework |> Seq.isEmpty then
if projectModel.HasLibReferences() then
traceWarnfn "Package %O contains libraries, but not for the selected TargetFramework %O in project %s."
(snd kv.Key) targetFramework project.FileName
| None -> ()

let copyLocal = defaultArg installSettings.CopyLocal true
let importTargets = defaultArg installSettings.ImportTargets true
Expand Down Expand Up @@ -1036,11 +1049,7 @@ module ProjectFile =
| _ -> ProjectOutputType.Library }
|> Seq.head

let getTargetFrameworkIdentifier (project:ProjectFile) = getProperty "TargetFrameworkIdentifier" project

let getTargetFrameworkProfile (project:ProjectFile) = getProperty "TargetFrameworkProfile" project

let getTargetProfile (project:ProjectFile) =
let getTargetProfile (project:ProjectFile) =
match getTargetFrameworkProfile project with
| Some profile when profile = "Client" ->
SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)
Expand Down
4 changes: 2 additions & 2 deletions src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<StartArguments>pack output D:\code\paketbug\output</StartArguments>
<StartArguments>install</StartArguments>
<StartArguments>restore</StartArguments>
<StartArguments>pack output "out/nuget" version 0.9.3 releaseNotes "[LanguageExtensions][New] New Ensure methods with exception parameter." include-referenced-projects</StartArguments>
<StartArguments>update</StartArguments>
<StartAction>Project</StartAction>
<StartProgram>paket.exe</StartProgram>
<StartWorkingDirectory>c:\code\Paketkopie</StartWorkingDirectory>
Expand All @@ -48,7 +48,7 @@
<StartWorkingDirectory>d:\code\paketrepro</StartWorkingDirectory>
<StartWorkingDirectory>D:\code\Paket\integrationtests\scenarios\i001270-net461\temp</StartWorkingDirectory>
<StartWorkingDirectory>C:\code\restore</StartWorkingDirectory>
<StartWorkingDirectory>D:\code\Journalist</StartWorkingDirectory>
<StartWorkingDirectory>D:\code\Paket\integrationtests\scenarios\i001442-warn-if-empty\temp</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down