Skip to content

Commit ae47fce

Browse files
authored
Merge pull request #3943 from mk185147/msbuild-condition-fix
Fix how msbuild condition is created based on target frameworks
2 parents 9f3fb42 + 313e51e commit ae47fce

5 files changed

Lines changed: 10 additions & 16 deletions

File tree

‎src/Paket.Core/PaketConfigFiles/ProjectFile.fs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ module ProjectFile =
824824
|> List.collect (fun libFolder ->
825825
match libFolder with
826826
| _ ->
827-
match PlatformMatching.getCondition referenceCondition allTargets libFolder.Targets with
827+
match PlatformMatching.getCondition referenceCondition libFolder.Targets with
828828
| "" -> []
829829
| condition ->
830830
let condition =
@@ -857,7 +857,7 @@ module ProjectFile =
857857
frameworkReferences
858858
|> List.partition (fun fr -> duplicates.Contains fr.Name)
859859

860-
match PlatformMatching.getCondition referenceCondition allTargets !assemblyTargets with
860+
match PlatformMatching.getCondition referenceCondition !assemblyTargets with
861861
| "" -> [condition,createItemGroup libFolder.Targets rest libraries,false]
862862
| lowerCondition ->
863863
[lowerCondition,createItemGroup !assemblyTargets specialFrameworkAssemblies [],true
@@ -874,7 +874,7 @@ module ProjectFile =
874874

875875
let frameworkSpecificTargetsFileConditions =
876876
frameworkSpecificTargets
877-
|> List.map (fun lib -> PlatformMatching.getCondition referenceCondition allTargets lib.Targets,createPropertyGroup (lib.FolderContents |> List.ofSeq))
877+
|> List.map (fun lib -> PlatformMatching.getCondition referenceCondition lib.Targets,createPropertyGroup (lib.FolderContents |> List.ofSeq))
878878

879879
let chooseNodes =
880880
match conditions with

‎src/Paket.Core/Versioning/PlatformMatching.fs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ let getTargetCondition (target:TargetProfile) =
215215
match platform with
216216
| DotNetFramework(FrameworkVersion.V5) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", "$(TargetFrameworkVersion) == 'v5.0'"
217217
| DotNetFramework(version) ->"$(TargetFrameworkIdentifier) == '.NETFramework'", sprintf "$(TargetFrameworkVersion) == '%O'" version
218-
| DotNet5WithOs(os) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", sprintf "($(TargetFrameworkVersion) == 'v5.0' And $(TargetPlatformIdentifier) == '%O')" os
219-
| DotNet5Windows(Net5WindowsVersion.V7_0) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", sprintf "($(TargetFrameworkVersion) == 'v5.0' And $(TargetPlatformIdentifier) == 'Windows')"
220-
| DotNet5Windows(version) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", sprintf "($(TargetFrameworkVersion) == 'v5.0' And $(TargetPlatformIdentifier) == 'Windows' And $(TargetPlatformVersion) == '%O')" version
218+
| DotNet5WithOs(os) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", sprintf "($(TargetFrameworkVersion) == 'v5.0' And '$(TargetPlatformIdentifier)' == '%O')" os
219+
| DotNet5Windows(Net5WindowsVersion.V7_0) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", sprintf "($(TargetFrameworkVersion) == 'v5.0' And '$(TargetPlatformIdentifier)' == 'Windows')"
220+
| DotNet5Windows(version) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", sprintf "($(TargetFrameworkVersion) == 'v5.0' And '$(TargetPlatformIdentifier)' == 'Windows' And '$(TargetPlatformVersion)' == '%O')" version
221221
| DotNetStandard(version) ->"$(TargetFrameworkIdentifier) == '.NETStandard'", sprintf "$(TargetFrameworkVersion) == '%O'" version
222222
| DotNetCoreApp(version) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", sprintf "$(TargetFrameworkVersion) == '%O'" version
223223
| DotNetUnity(DotNetUnityVersion.V3_5_Full as version) ->
@@ -248,7 +248,7 @@ let getTargetCondition (target:TargetProfile) =
248248
| Unsupported s -> "", ""
249249
| TargetProfile.PortableProfile p -> sprintf "$(TargetFrameworkProfile) == '%O'" p.ProfileName,""
250250

251-
let getCondition (referenceCondition:string option) (allTargets: TargetProfile Set list) (targets : TargetProfile Set) =
251+
let getCondition (referenceCondition:string option) (targets : TargetProfile Set) =
252252
let inline CheckIfFullyInGroup typeName matchF filterRestF (processed,targets) =
253253
let fullyContained =
254254
KnownTargetProfiles.AllDotNetProfiles

‎src/Paket.Core/Versioning/Requirements.fs‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,7 @@ type FrameworkRestriction =
299299
x.RawFormular.IsMatch tp
300300

301301
member x.ToMSBuildCondition() =
302-
let formulas =
303-
[for fr in x.RepresentedFrameworks do
304-
let fr = fr.ToString()
305-
yield sprintf "('$(TargetFramework)' == '%s')" fr
306-
if fr.Contains "." then
307-
yield sprintf "('$(TargetFramework)' == '%s')" (fr.Replace(".",""))]
308-
String.Join(" OR ",formulas)
302+
PlatformMatching.getCondition None x.RepresentedFrameworks
309303

310304
override x.Equals(y) =
311305
match y with

‎tests/Paket.Tests/InstallModel/Penalty/FrameworkConditionsSpecs.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ open Paket.Domain
77

88
open Paket.PlatformMatching
99

10-
let getCondition cond targets = getCondition cond [targets] targets
10+
let getCondition cond targets = getCondition cond targets
1111

1212
[<Test>]
1313
let ``should create empty condition for empty profile list``() =

‎tests/Paket.Tests/InstallModel/Xml/RxXaml.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ let expected = """
3333
</Reference>
3434
</ItemGroup>
3535
</When>
36-
<When Condition="($(TargetFrameworkIdentifier) == 'WindowsPhoneApp') Or ($(TargetFrameworkIdentifier) == 'MonoAndroid' And ($(TargetFrameworkVersion) == 'v10.0' Or $(TargetFrameworkVersion) == 'v7.0' Or $(TargetFrameworkVersion) == 'v7.1' Or $(TargetFrameworkVersion) == 'v8.0' Or $(TargetFrameworkVersion) == 'v8.1' Or $(TargetFrameworkVersion) == 'v9.0')) Or ($(TargetFrameworkIdentifier) == 'MonoTouch') Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And ($(TargetFrameworkVersion) == 'v1.0' Or $(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v2.0' Or $(TargetFrameworkVersion) == 'v2.1' Or $(TargetFrameworkVersion) == 'v2.2' Or $(TargetFrameworkVersion) == 'v3.0' Or $(TargetFrameworkVersion) == 'v3.1' Or $(TargetFrameworkVersion) == 'v5.0' Or ($(TargetFrameworkVersion) == 'v5.0' And $(TargetPlatformIdentifier) == 'Windows' And $(TargetPlatformVersion) == '10.0.17763.0') Or ($(TargetFrameworkVersion) == 'v5.0' And $(TargetPlatformIdentifier) == 'Windows' And $(TargetPlatformVersion) == '10.0.18362.0') Or ($(TargetFrameworkVersion) == 'v5.0' And $(TargetPlatformIdentifier) == 'Windows' And $(TargetPlatformVersion) == '10.0.19041.0') Or ($(TargetFrameworkVersion) == 'v5.0' And $(TargetPlatformIdentifier) == 'Windows' And $(TargetPlatformVersion) == '8.0') Or ($(TargetFrameworkVersion) == 'v5.0' And $(TargetPlatformIdentifier) == 'Windows') Or ($(TargetFrameworkVersion) == 'v5.0' And $(TargetPlatformIdentifier) == 'android') Or ($(TargetFrameworkVersion) == 'v5.0' And $(TargetPlatformIdentifier) == 'ios') Or ($(TargetFrameworkVersion) == 'v5.0' And $(TargetPlatformIdentifier) == 'macos') Or ($(TargetFrameworkVersion) == 'v5.0' And $(TargetPlatformIdentifier) == 'tvos') Or ($(TargetFrameworkVersion) == 'v5.0' And $(TargetPlatformIdentifier) == 'watchos'))) Or ($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.2' Or $(TargetFrameworkVersion) == 'v1.3' Or $(TargetFrameworkVersion) == 'v1.4' Or $(TargetFrameworkVersion) == 'v1.5' Or $(TargetFrameworkVersion) == 'v1.6' Or $(TargetFrameworkVersion) == 'v2.0' Or $(TargetFrameworkVersion) == 'v2.1')) Or ($(TargetFrameworkProfile) == 'Profile32') Or ($(TargetFrameworkIdentifier) == 'Xamarin.iOS') Or ($(TargetFrameworkIdentifier) == 'Xamarin.Mac') Or ($(TargetFrameworkIdentifier) == 'Xamarin.tvOS') Or ($(TargetFrameworkIdentifier) == 'Xamarin.watchOS')">
36+
<When Condition="($(TargetFrameworkIdentifier) == 'WindowsPhoneApp') Or ($(TargetFrameworkIdentifier) == 'MonoAndroid' And ($(TargetFrameworkVersion) == 'v10.0' Or $(TargetFrameworkVersion) == 'v7.0' Or $(TargetFrameworkVersion) == 'v7.1' Or $(TargetFrameworkVersion) == 'v8.0' Or $(TargetFrameworkVersion) == 'v8.1' Or $(TargetFrameworkVersion) == 'v9.0')) Or ($(TargetFrameworkIdentifier) == 'MonoTouch') Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And ($(TargetFrameworkVersion) == 'v1.0' Or $(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v2.0' Or $(TargetFrameworkVersion) == 'v2.1' Or $(TargetFrameworkVersion) == 'v2.2' Or $(TargetFrameworkVersion) == 'v3.0' Or $(TargetFrameworkVersion) == 'v3.1' Or $(TargetFrameworkVersion) == 'v5.0' Or ($(TargetFrameworkVersion) == 'v5.0' And '$(TargetPlatformIdentifier)' == 'Windows' And '$(TargetPlatformVersion)' == '10.0.17763.0') Or ($(TargetFrameworkVersion) == 'v5.0' And '$(TargetPlatformIdentifier)' == 'Windows' And '$(TargetPlatformVersion)' == '10.0.18362.0') Or ($(TargetFrameworkVersion) == 'v5.0' And '$(TargetPlatformIdentifier)' == 'Windows' And '$(TargetPlatformVersion)' == '10.0.19041.0') Or ($(TargetFrameworkVersion) == 'v5.0' And '$(TargetPlatformIdentifier)' == 'Windows' And '$(TargetPlatformVersion)' == '8.0') Or ($(TargetFrameworkVersion) == 'v5.0' And '$(TargetPlatformIdentifier)' == 'Windows') Or ($(TargetFrameworkVersion) == 'v5.0' And '$(TargetPlatformIdentifier)' == 'android') Or ($(TargetFrameworkVersion) == 'v5.0' And '$(TargetPlatformIdentifier)' == 'ios') Or ($(TargetFrameworkVersion) == 'v5.0' And '$(TargetPlatformIdentifier)' == 'macos') Or ($(TargetFrameworkVersion) == 'v5.0' And '$(TargetPlatformIdentifier)' == 'tvos') Or ($(TargetFrameworkVersion) == 'v5.0' And '$(TargetPlatformIdentifier)' == 'watchos'))) Or ($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.2' Or $(TargetFrameworkVersion) == 'v1.3' Or $(TargetFrameworkVersion) == 'v1.4' Or $(TargetFrameworkVersion) == 'v1.5' Or $(TargetFrameworkVersion) == 'v1.6' Or $(TargetFrameworkVersion) == 'v2.0' Or $(TargetFrameworkVersion) == 'v2.1')) Or ($(TargetFrameworkProfile) == 'Profile32') Or ($(TargetFrameworkIdentifier) == 'Xamarin.iOS') Or ($(TargetFrameworkIdentifier) == 'Xamarin.Mac') Or ($(TargetFrameworkIdentifier) == 'Xamarin.tvOS') Or ($(TargetFrameworkIdentifier) == 'Xamarin.watchOS')">
3737
<ItemGroup>
3838
<Reference Include="System.Reactive.Windows.Threading">
3939
<HintPath>..\..\..\Rx-XAML\lib\portable-win81+wpa81\System.Reactive.Windows.Threading.dll</HintPath>

0 commit comments

Comments
 (0)