Skip to content

Commit

Permalink
Merge pull request #1028 from matthid/groups
Browse files Browse the repository at this point in the history
Fix msbuild warning MSB4130, references #1026
  • Loading branch information
forki committed Aug 31, 2015
2 parents c512a58 + 125a8a7 commit e9e094c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/Paket.Core/PlatformMatching.fs
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,10 @@ let getCondition (referenceCondition:string option) (targets : TargetProfile lis
|> fun s ->
match referenceCondition with
| None -> s
| Some condition ->
| Some condition ->
// msbuild triggers a warning MSB4130 when we leave out the quotes around the condition
// and add the condition at the end
if s = "$(TargetFrameworkIdentifier) == 'true'" then
sprintf "$(%s) == 'True'" condition
sprintf "'$(%s)' == 'True'" condition
else
sprintf "%s And $(%s) == 'True'" s condition
sprintf "'$(%s)' == 'True' And %s" condition s
43 changes: 41 additions & 2 deletions tests/Paket.Tests/InstallModel/Xml/Fantomas.fs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ let fullDocWithRefernceCondition = """<?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')" />
<Choose>
<When Condition="$(LEGACY) == 'True'">
<When Condition="'$(LEGACY)' == 'True'">
<ItemGroup>
<Reference Include="FantomasLib">
<HintPath>..\..\..\Fantomas\lib\FantomasLib.dll</HintPath>
Expand Down Expand Up @@ -126,4 +126,43 @@ let ``should generate full Xml with reference condition for Fantomas 1.5``() =

project.Document.OuterXml
|> normalizeXml
|> shouldEqual (normalizeXml fullDocWithRefernceCondition)
|> shouldEqual (normalizeXml fullDocWithRefernceCondition)

let fullDocWithRefernceConditionAndFrameworkRestriction = """<?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')" />
<Choose>
<When Condition="'$(LEGACY)' == 'True' And $(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
<ItemGroup>
<Reference Include="FantomasLib">
<HintPath>..\..\..\Fantomas\lib\FantomasLib.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
</Project>"""

[<Test>]
let ``should generate full Xml with reference condition and framework restrictions without msbuild warning``() =
// msbuild triggers a warning MSB4130 when we leave out the quotes around $(LEGACY) and add the condition at the end
let model =
InstallModel.CreateFromLibs(PackageName "Fantomas", SemVer.Parse "1.5.0", [FrameworkRestriction.Exactly (FrameworkIdentifier.DotNetFramework FrameworkVersion.V4_5)],
[ @"..\Fantomas\lib\FantomasLib.dll"
@"..\Fantomas\lib\FSharp.Core.dll"
@"..\Fantomas\lib\Fantomas.exe" ],
[],
Nuspec.Explicit ["FantomasLib.dll"])

let project = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value
let completeModel = [(Constants.MainDependencyGroup, (PackageName "Fantomas")),(model,model)] |> Map.ofSeq
let settings =
{ InstallSettings.Default
with ReferenceCondition = Some "LEGACY" }
let used = [(Constants.MainDependencyGroup, (PackageName "fantoMas")), (InstallSettings.Default,settings)] |> Map.ofSeq
project.UpdateReferences(completeModel,used,false)

project.Document.OuterXml
|> normalizeXml
|> shouldEqual (normalizeXml fullDocWithRefernceConditionAndFrameworkRestriction)

0 comments on commit e9e094c

Please sign in to comment.