Skip to content

Commit

Permalink
$(SolutionDir) in ProjectReference include attribute will be parsed - f…
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jan 12, 2016
1 parent e9205aa commit ccf8462
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 10 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.42.4 - 12.01.2016
* BUGFIX: $(SolutionDir) in ProjectReference include attribute will be parsed - https://github.com/fsprojects/Paket/issues/1377

#### 2.42.3 - 11.01.2016
* BUGFIX: Restore groups sequentially - https://github.com/fsprojects/Paket/issues/1371

Expand Down
27 changes: 18 additions & 9 deletions src/Paket.Core/ProjectFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,12 @@ type ProjectFile =
then data
else addData data node

this.Document
|> getDescendants "PropertyGroup"
|> Seq.fold handleElement defaultProperties
|> Map.tryFind propertyName
let map =
this.Document
|> getDescendants "PropertyGroup"
|> Seq.fold handleElement defaultProperties

Map.tryFind propertyName map

member this.GetProperty propertyName =
this.GetPropertyWithDefaults propertyName Map.empty<string, string>
Expand Down Expand Up @@ -888,12 +890,19 @@ type ProjectFile =
| None -> failwithf "unable to parse %s" node.Name

[for node in this.Document |> getDescendants "ProjectReference" ->
{ Path =
let p = node.Attributes.["Include"].Value |> normalizePath
if Path.IsPathRooted p then Path.GetFullPath p else
let path =
let normalizedPath = node.Attributes.["Include"].Value |> normalizePath
if normalizedPath.Contains("$(SolutionDir)") then
match this.GetProperty("SolutionDir") with
| Some slnDir -> normalizedPath.Replace("$(SolutionDir)",slnDir)
| None -> normalizedPath
else normalizedPath

{ Path =
if Path.IsPathRooted path then Path.GetFullPath path else
let di = FileInfo(normalizePath this.FileName).Directory
Path.Combine(di.FullName,p) |> Path.GetFullPath
RelativePath = node.Attributes.["Include"].Value
Path.Combine(di.FullName,path) |> Path.GetFullPath
RelativePath = path
Name = forceGetInnerText node "Name"
GUID = forceGetInnerText node "Project" |> Guid.Parse }]

Expand Down
3 changes: 3 additions & 0 deletions tests/Paket.Tests/Paket.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@
<None Include="ProjectFile\TestData\Project3.fsprojtest">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ProjectFile\TestData\Project4.fsprojtest">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ProjectFile\TestData\ProjectWithConditions.fsprojtest">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
12 changes: 11 additions & 1 deletion tests/Paket.Tests/ProjectFile/InterProjectDependencySpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,14 @@ let ``should detect Guids for dependencies in Project2 proj file``() =
p.GetProjectGuid() |> shouldEqual (Guid.Parse "e789c72a-5cfd-436b-8ef1-61aa2852a89f")
p.GetInterProjectDependencies()
|> List.map (fun p -> p.GUID.ToString())
|> shouldEqual ["09b32f18-0c20-4489-8c83-5106d5c04c93"; "7bab0ae2-089f-4761-b138-a717aa2f86c5"]
|> shouldEqual ["09b32f18-0c20-4489-8c83-5106d5c04c93"; "7bab0ae2-089f-4761-b138-a717aa2f86c5"]


[<Test>]
let ``should detect solution path for dependencies in Project4 proj file``() =
let paths =
ProjectFile.TryLoad("./ProjectFile/TestData/Project4.fsprojtest").Value.GetInterProjectDependencies()
|> List.map (fun p -> p.RelativePath)

paths.[0] |> shouldEqual "..\\..\\src\\Paket\\Paket.fsproj"
paths.[1] |> shouldEqual "..\\Paket.Core\\Paket.Core.fsproj"
115 changes: 115 additions & 0 deletions tests/Paket.Tests/ProjectFile/TestData/Project4.fsprojtest
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.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>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>e789c72a-5cfd-436b-8ef1-61aa2852a89f</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Paket.Tests</RootNamespace>
<AssemblyName>Paket.Tests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFSharpCoreVersion>4.3.0.0</TargetFSharpCoreVersion>
<Name>Paket.Tests</Name>
<TargetFrameworkProfile />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<OutputPath>bin\Fail\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Debug\fsharp_project_scaffold_tests.XML</DocumentationFile>
<StartAction>Project</StartAction>
<StartProgram>
</StartProgram>
<StartArguments>
</StartArguments>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Release\Paket.Tests.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
</PropertyGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '11.0'">
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</Otherwise>
</Choose>
<Import Project="$(FSharpTargetsPath)" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<ItemGroup>
<Compile Include="FsUnit.fs" />
<Compile Include="TestHelpers.fs" />
<Compile Include="SemVerSpecs.fs" />
<Compile Include="NugetVersionRangeSpecs.fs" />
<Compile Include="FilterVersionSpecs.fs" />
<Compile Include="DependencyGraphSpecs.fs" />
<Compile Include="CyclicGraphSpecs.fs" />
<Compile Include="ConflictGraphSpecs.fs" />
<Compile Include="ConfigVersionRangeSpecs.fs" />
<Compile Include="LoadConfigSpecs.fs" />
<Compile Include="ResolveConfigSpecs.fs" />
<Compile Include="LockFileGenerationSpecs.fs" />
<Compile Include="LockFileGenerationWithMutlipleSourcesSpecs.fs" />
<Compile Include="LockFileParserSpecs.fs" />
<Compile Include="LockFileWithMultipleSourcesParserSpecs.fs" />
<Content Include="TestData\Project1.fsproj">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Compile Include="ProjectFileSpecs.fs" />
<None Include="packages" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>True</Private>
<HintPath>..\..\lib\FSharp\FSharp.Core.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SolutionDir)src\Paket\Paket.fsproj">
<Name>Paket</Name>
<Project>{09b32f18-0c20-4489-8c83-5106d5c04c93}</Project>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="..\Paket.Core\Paket.Core.fsproj">
<Name>Paket.Core</Name>
<Project>{7bab0ae2-089f-4761-b138-a717aa2f86c5}</Project>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<!-- 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>
-->
</Project>

0 comments on commit ccf8462

Please sign in to comment.