Skip to content

Commit

Permalink
Putting .props and .targets import project on correct location in pro…
Browse files Browse the repository at this point in the history
…ject files - fixes #1219
  • Loading branch information
forki committed Nov 13, 2015
1 parent f3ea90b commit 5be086f
Show file tree
Hide file tree
Showing 37 changed files with 279 additions and 66 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 2.24.7 - 13.11.2015
* Putting .props and .targets import project on correct location in project files - https://github.com/fsprojects/Paket/issues/1219

#### 2.24.6 - 12.11.2015
* Propagate framework restriction with top-level dependencies correctly - https://github.com/fsprojects/Paket/issues/1215

Expand Down
11 changes: 10 additions & 1 deletion integrationtests/Paket.IntegrationTests/InstallSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,13 @@ let ``#1135 should keep lockfile stable when using framework restrictions``() =
let newLockFile = install "i001135-stable-install-on-framework-restrictions"
let oldLockFile = LockFile.LoadFrom(Path.Combine(originalScenarioPath "i001135-stable-install-on-framework-restrictions","paket.lock"))
newLockFile.ToString()
|> shouldEqual (oldLockFile.ToString())
|> shouldEqual (oldLockFile.ToString())

[<Test>]
let ``#1219 install props``() =
let newLockFile = install "i001219-props-files"
let newFile = Path.Combine(scenarioTempPath "i001219-props-files","MyClassLibrary","MyClassLibrary","MyClassLibrary.csproj")
let oldFile = Path.Combine(originalScenarioPath "i001219-props-files","MyClassLibrary","MyClassLibrary","MyClassLibrary.csprojtemplate")
let s1 = File.ReadAllText oldFile |> normalizeLineEndings
let s2 = File.ReadAllText newFile |> normalizeLineEndings
s1 |> shouldEqual s2
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,85 @@
<?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')" />
<Import Project="..\..\packages\MultiTarget\build\MultiTarget.props" Condition="Exists('..\..\packages\MultiTarget\build\MultiTarget.props')" Label="Paket" />
<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.2</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) == 'v3.5'">
<ItemGroup>
<Reference Include="Dapper">
<HintPath>..\..\packages\Dapper\lib\net35\Dapper.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0')">
<ItemGroup>
<Reference Include="Dapper">
<HintPath>..\..\packages\Dapper\lib\net40\Dapper.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6')">
<ItemGroup>
<Reference Include="Dapper">
<HintPath>..\..\packages\Dapper\lib\net45\Dapper.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="..\..\packages\MultiTarget\build\MultiTarget.targets" Condition="Exists('..\..\packages\MultiTarget\build\MultiTarget.targets')" Label="Paket" />
</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,2 @@
MultiTarget
Dapper
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
run ./.paket/paket.exe install and check out csproj file.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source nuget_repo

nuget MultiTarget
nuget Dapper
8 changes: 4 additions & 4 deletions src/Paket.Bootstrapper/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
[assembly: AssemblyTitleAttribute("Paket.Bootstrapper")]
[assembly: AssemblyProductAttribute("Paket")]
[assembly: AssemblyDescriptionAttribute("A package dependency manager for .NET with support for NuGet packages and GitHub repositories.")]
[assembly: AssemblyVersionAttribute("2.24.6")]
[assembly: AssemblyFileVersionAttribute("2.24.6")]
[assembly: AssemblyInformationalVersionAttribute("2.24.6")]
[assembly: AssemblyVersionAttribute("2.24.7")]
[assembly: AssemblyFileVersionAttribute("2.24.7")]
[assembly: AssemblyInformationalVersionAttribute("2.24.7")]
namespace System {
internal static class AssemblyVersionInformation {
internal const string Version = "2.24.6";
internal const string Version = "2.24.7";
}
}
8 changes: 4 additions & 4 deletions src/Paket.Core/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ open System.Reflection
[<assembly: AssemblyProductAttribute("Paket")>]
[<assembly: AssemblyCompanyAttribute("Paket team")>]
[<assembly: AssemblyDescriptionAttribute("A package dependency manager for .NET with support for NuGet packages and GitHub repositories.")>]
[<assembly: AssemblyVersionAttribute("2.24.6")>]
[<assembly: AssemblyFileVersionAttribute("2.24.6")>]
[<assembly: AssemblyInformationalVersionAttribute("2.24.6")>]
[<assembly: AssemblyVersionAttribute("2.24.7")>]
[<assembly: AssemblyFileVersionAttribute("2.24.7")>]
[<assembly: AssemblyInformationalVersionAttribute("2.24.7")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "2.24.6"
let [<Literal>] Version = "2.24.7"
55 changes: 42 additions & 13 deletions src/Paket.Core/ProjectFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ type ProjectFile =
|> addChild (this.CreateNode("Paket","True"))
|> itemGroup.AppendChild
|> ignore
| Reference.FrameworkAssemblyReference frameworkAssembly ->
| Reference.FrameworkAssemblyReference frameworkAssembly ->
this.CreateNode("Reference")
|> addAttribute "Include" frameworkAssembly
|> addChild (this.CreateNode("Paket","True"))
Expand All @@ -381,14 +381,14 @@ type ProjectFile =
let createPropertyGroup references =
let propertyGroup = this.CreateNode("PropertyGroup")

let propertyNames =
let propertyNames =
references
|> Seq.choose (fun lib ->
if not importTargets then None else
match lib with
| Reference.Library _ -> None
| Reference.FrameworkAssemblyReference _ -> None
| Reference.TargetsFile targetsFile ->
| Reference.TargetsFile targetsFile ->
let fi = new FileInfo(normalizePath targetsFile)
let propertyName = "__paket__" + fi.Name.ToString().Replace(" ","_").Replace(".","_")

Expand Down Expand Up @@ -432,7 +432,7 @@ type ProjectFile =
whenNode.AppendChild(itemGroup) |> ignore
containsReferences := true
whenNode)
|> List.iter(fun node -> chooseNode.AppendChild(node) |> ignore)
|> List.iter(fun node -> chooseNode.AppendChild(node) |> ignore)

if !containsReferences then chooseNode else this.CreateNode("Choose")

Expand All @@ -453,22 +453,39 @@ type ProjectFile =
whenNode.AppendChild(propertyGroup) |> ignore
containsProperties := true
whenNode)
|> List.iter(fun node -> propertyChooseNode.AppendChild(node) |> ignore)
|> List.iter(fun node -> propertyChooseNode.AppendChild(node) |> ignore)

(targetsFileConditions |> List.map (fun (_,(propertyNames,_)) -> propertyNames)),
(if !containsProperties then propertyChooseNode else this.CreateNode("Choose"))


let propertyNameNodes =
let propsNodes =
propertyNames
|> Seq.concat
|> Seq.distinctBy (fun (x,_,_) -> x)
|> Seq.filter (fun (propertyName,path,buildPath) -> propertyName.ToLower().EndsWith "props")
|> Seq.map (fun (propertyName,path,buildPath) ->
let fileName =
match propertyName.ToLower() with
| _ when propertyChooseNode.ChildNodes.Count = 0 -> path
| name when name.EndsWith "props" -> sprintf "%s$(%s).props" buildPath propertyName
| _ -> failwithf "Unknown .props filename %s" propertyName

this.CreateNode("Import")
|> addAttribute "Project" fileName
|> addAttribute "Condition" (sprintf "Exists('%s')" fileName)
|> addAttribute "Label" "Paket")
|> Seq.toList

let targetsNodes =
propertyNames
|> Seq.concat
|> Seq.distinctBy (fun (x,_,_) -> x)
|> Seq.filter (fun (propertyName,path,buildPath) -> propertyName.ToLower().EndsWith "props" |> not)
|> Seq.map (fun (propertyName,path,buildPath) ->
let fileName =
match propertyName.ToLower() with
| _ when propertyChooseNode.ChildNodes.Count = 0 -> path
| name when name.EndsWith "props" ->
sprintf "%s$(%s).props" buildPath propertyName
| name when name.EndsWith "targets" ->
sprintf "%s$(%s).targets" buildPath propertyName
| _ -> failwithf "Unknown .targets filename %s" propertyName
Expand All @@ -481,14 +498,14 @@ type ProjectFile =

let analyzersNode = this.GenerateAnalyzersXml model

propertyNameNodes,chooseNode,propertyChooseNode,analyzersNode
propsNodes,targetsNodes,chooseNode,propertyChooseNode,analyzersNode

member this.RemovePaketNodes() =
this.DeletePaketNodes("Analyzer")
this.DeletePaketNodes("Reference")

let rec PaketNodes (node:XmlNode) =
[for node in node.ChildNodes do
[for node in node.ChildNodes do
if node.Name.Contains("__paket__") ||
(node.Name = "Import" && match node |> getAttribute "Project" with Some v -> v.Contains("__paket__") | None -> false) ||
(node |> withAttributeValue "Label" "Paket")
Expand All @@ -498,7 +515,7 @@ type ProjectFile =

for node in PaketNodes this.Document do
let parent = node.ParentNode
try
try
node.ParentNode.RemoveChild(node) |> ignore
with
| _ -> ()
Expand Down Expand Up @@ -531,16 +548,28 @@ type ProjectFile =
let importTargets = defaultArg installSettings.ImportTargets true

this.GenerateXml(projectModel,copyLocal,importTargets,installSettings.ReferenceCondition))
|> Seq.iter (fun (propertyNameNodes,chooseNode,propertyChooseNode, analyzersNode) ->
|> Seq.iter (fun (propsNodes,targetsNodes,chooseNode,propertyChooseNode, analyzersNode) ->
if chooseNode.ChildNodes.Count > 0 then
this.ProjectNode.AppendChild chooseNode |> ignore

if propertyChooseNode.ChildNodes.Count > 0 then
this.ProjectNode.AppendChild propertyChooseNode |> ignore

let i = ref 0
while !i < this.ProjectNode.ChildNodes.Count && this.ProjectNode.ChildNodes.[!i].OuterXml.ToString().ToLower().StartsWith("<import") do
incr i

if !i = 0 then
propsNodes
|> Seq.iter (this.ProjectNode.AppendChild >> ignore)
else
propsNodes
|> Seq.iter (fun n -> this.ProjectNode.InsertAfter(n,this.ProjectNode.ChildNodes.[!i-1]) |> ignore)

propertyNameNodes
targetsNodes
|> Seq.iter (this.ProjectNode.AppendChild >> ignore)


if analyzersNode.ChildNodes.Count > 0 then
this.ProjectNode.AppendChild analyzersNode |> ignore
)
Expand Down
8 changes: 4 additions & 4 deletions src/Paket.PowerShell/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ open System.Reflection
[<assembly: AssemblyProductAttribute("Paket")>]
[<assembly: AssemblyCompanyAttribute("Paket team")>]
[<assembly: AssemblyDescriptionAttribute("A package dependency manager for .NET with support for NuGet packages and GitHub repositories.")>]
[<assembly: AssemblyVersionAttribute("2.24.6")>]
[<assembly: AssemblyFileVersionAttribute("2.24.6")>]
[<assembly: AssemblyInformationalVersionAttribute("2.24.6")>]
[<assembly: AssemblyVersionAttribute("2.24.7")>]
[<assembly: AssemblyFileVersionAttribute("2.24.7")>]
[<assembly: AssemblyInformationalVersionAttribute("2.24.7")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "2.24.6"
let [<Literal>] Version = "2.24.7"
8 changes: 4 additions & 4 deletions src/Paket/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ open System.Reflection
[<assembly: AssemblyProductAttribute("Paket")>]
[<assembly: AssemblyCompanyAttribute("Paket team")>]
[<assembly: AssemblyDescriptionAttribute("A package dependency manager for .NET with support for NuGet packages and GitHub repositories.")>]
[<assembly: AssemblyVersionAttribute("2.24.6")>]
[<assembly: AssemblyFileVersionAttribute("2.24.6")>]
[<assembly: AssemblyInformationalVersionAttribute("2.24.6")>]
[<assembly: AssemblyVersionAttribute("2.24.7")>]
[<assembly: AssemblyFileVersionAttribute("2.24.7")>]
[<assembly: AssemblyInformationalVersionAttribute("2.24.7")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "2.24.6"
let [<Literal>] Version = "2.24.7"
Loading

0 comments on commit 5be086f

Please sign in to comment.