diff --git a/.paket/Paket.Restore.targets b/.paket/Paket.Restore.targets
index bbeec153f5..4deb15bcd1 100644
--- a/.paket/Paket.Restore.targets
+++ b/.paket/Paket.Restore.targets
@@ -1,325 +1,322 @@
-
-
-
-
-
- $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
-
- $(MSBuildVersion)
- 15.0.0
- false
- true
-
- true
- $(MSBuildThisFileDirectory)
- $(MSBuildThisFileDirectory)..\
- $(PaketRootPath)paket-files\paket.restore.cached
- $(PaketRootPath)paket.lock
- classic
- proj
- assembly
- native
- /Library/Frameworks/Mono.framework/Commands/mono
- mono
-
-
- $(PaketRootPath)paket.bootstrapper.exe
- $(PaketToolsPath)paket.bootstrapper.exe
- $([System.IO.Path]::GetDirectoryName("$(PaketBootStrapperExePath)"))\
-
- "$(PaketBootStrapperExePath)"
- $(MonoPath) --runtime=v4.0.30319 "$(PaketBootStrapperExePath)"
-
-
-
-
- true
- true
-
-
- True
-
-
- False
-
- $(BaseIntermediateOutputPath.TrimEnd('\').TrimEnd('\/'))
-
-
-
-
-
-
-
-
- $(PaketRootPath)paket
- $(PaketToolsPath)paket
-
-
-
-
-
- $(PaketRootPath)paket.exe
- $(PaketToolsPath)paket.exe
-
-
-
-
-
- <_DotnetToolsJson Condition="Exists('$(PaketRootPath)/.config/dotnet-tools.json')">$([System.IO.File]::ReadAllText("$(PaketRootPath)/.config/dotnet-tools.json"))
- <_ConfigContainsPaket Condition=" '$(_DotnetToolsJson)' != ''">$(_DotnetToolsJson.Contains('"paket"'))
- <_ConfigContainsPaket Condition=" '$(_ConfigContainsPaket)' == ''">false
-
-
-
-
-
-
-
-
-
-
- <_PaketCommand>dotnet paket
-
-
-
-
-
- $(PaketToolsPath)paket
- $(PaketBootStrapperExeDir)paket
-
-
- paket
-
-
-
-
- <_PaketExeExtension>$([System.IO.Path]::GetExtension("$(PaketExePath)"))
- <_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(_PaketExeExtension)' == '.dll' ">dotnet "$(PaketExePath)"
- <_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(OS)' != 'Windows_NT' AND '$(_PaketExeExtension)' == '.exe' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"
- <_PaketCommand Condition=" '$(_PaketCommand)' == '' ">"$(PaketExePath)"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
- $(NoWarn);NU1603;NU1604;NU1605;NU1608
- false
- true
-
-
-
-
-
-
-
-
- $([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)'))
-
-
-
-
-
-
- $([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`)[0].Replace(`"`, ``).Replace(` `, ``))
- $([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`)[1].Replace(`"`, ``).Replace(` `, ``))
-
-
-
-
- %(PaketRestoreCachedKeyValue.Value)
- %(PaketRestoreCachedKeyValue.Value)
-
-
-
-
- true
- false
- true
-
-
-
+
+
+
+
+ $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
+
+ $(MSBuildVersion)
+ 15.0.0
+ false
+ true
+
+ true
+ $(MSBuildThisFileDirectory)
+ $(MSBuildThisFileDirectory)..\
+ $(PaketRootPath)paket-files\paket.restore.cached
+ $(PaketRootPath)paket.lock
+ classic
+ proj
+ assembly
+ native
+ /Library/Frameworks/Mono.framework/Commands/mono
+ mono
+
+
+ $(PaketRootPath)paket.bootstrapper.exe
+ $(PaketToolsPath)paket.bootstrapper.exe
+ $([System.IO.Path]::GetDirectoryName("$(PaketBootStrapperExePath)"))\
+
+ "$(PaketBootStrapperExePath)"
+ $(MonoPath) --runtime=v4.0.30319 "$(PaketBootStrapperExePath)"
+
+
+
+
+ true
+ true
+
+
+ True
+
+
+ False
+
+ $(BaseIntermediateOutputPath.TrimEnd('\').TrimEnd('\/'))
+
+
+
+
+
+
+
+
+ $(PaketRootPath)paket
+ $(PaketToolsPath)paket
+
+
+
+
+
+ $(PaketRootPath)paket.exe
+ $(PaketToolsPath)paket.exe
+
+
+
+
+
+ <_DotnetToolsJson Condition="Exists('$(PaketRootPath)/.config/dotnet-tools.json')">$([System.IO.File]::ReadAllText("$(PaketRootPath)/.config/dotnet-tools.json"))
+ <_ConfigContainsPaket Condition=" '$(_DotnetToolsJson)' != ''">$(_DotnetToolsJson.Contains('"paket"'))
+ <_ConfigContainsPaket Condition=" '$(_ConfigContainsPaket)' == ''">false
+
+
+
+
+
+
+
+
+
+
+ <_PaketCommand>dotnet paket
+
+
+
+
+
+ $(PaketToolsPath)paket
+ $(PaketBootStrapperExeDir)paket
+
+
+ paket
+
+
+
+
+ <_PaketExeExtension>$([System.IO.Path]::GetExtension("$(PaketExePath)"))
+ <_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(_PaketExeExtension)' == '.dll' ">dotnet "$(PaketExePath)"
+ <_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(OS)' != 'Windows_NT' AND '$(_PaketExeExtension)' == '.exe' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"
+ <_PaketCommand Condition=" '$(_PaketCommand)' == '' ">"$(PaketExePath)"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ $(NoWarn);NU1603;NU1604;NU1605;NU1608
+ false
+ true
+
+
+
+
+
+
+
+
+ $([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)'))
+
+
+
+
+
+
+ $([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`)[0].Replace(`"`, ``).Replace(` `, ``))
+ $([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`)[1].Replace(`"`, ``).Replace(` `, ``))
+
+
+
+
+ %(PaketRestoreCachedKeyValue.Value)
+ %(PaketRestoreCachedKeyValue.Value)
+
+
+
+
+ true
+ false
+ true
+
+
+
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(PaketIntermediateOutputPath)\$(MSBuildProjectFile).paket.references.cached
-
- $(MSBuildProjectFullPath).paket.references
-
- $(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references
-
- $(MSBuildProjectDirectory)\paket.references
-
- false
- true
- true
- references-file-or-cache-not-found
-
-
-
-
- $([System.IO.File]::ReadAllText('$(PaketReferencesCachedFilePath)'))
- $([System.IO.File]::ReadAllText('$(PaketOriginalReferencesFilePath)'))
- references-file
- false
-
-
-
-
- false
-
-
-
-
- true
- target-framework '$(TargetFramework)' or '$(TargetFrameworks)' files @(PaketResolvedFilePaths)
-
-
-
-
-
-
-
-
-
-
- false
- true
-
-
-
-
-
-
-
-
-
-
- $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',').Length)
- $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])
- $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])
- $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[4])
- $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[5])
- $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[6])
- $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[7])
- $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[8])
-
-
- %(PaketReferencesFileLinesInfo.PackageVersion)
- All
- runtime
- $(ExcludeAssets);contentFiles
- $(ExcludeAssets);build;buildMultitargeting;buildTransitive
- %(PaketReferencesFileLinesInfo.Aliases)
- true
- true
-
-
-
-
-
- $(PaketIntermediateOutputPath)/$(MSBuildProjectFile).paket.clitools
-
-
-
-
-
-
-
-
- $([System.String]::Copy('%(PaketCliToolFileLines.Identity)').Split(',')[0])
- $([System.String]::Copy('%(PaketCliToolFileLines.Identity)').Split(',')[1])
-
-
- %(PaketCliToolFileLinesInfo.PackageVersion)
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(PaketIntermediateOutputPath)\$(MSBuildProjectFile).paket.references.cached
+
+ $(MSBuildProjectFullPath).paket.references
+
+ $(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references
+
+ $(MSBuildProjectDirectory)\paket.references
+
+ false
+ true
+ true
+ references-file-or-cache-not-found
+
+
+
+
+ $([System.IO.File]::ReadAllText('$(PaketReferencesCachedFilePath)'))
+ $([System.IO.File]::ReadAllText('$(PaketOriginalReferencesFilePath)'))
+ references-file
+ false
+
+
+
+
+ false
+
+
+
+
+ true
+ target-framework '$(TargetFramework)' or '$(TargetFrameworks)' files @(PaketResolvedFilePaths)
+
+
+
+
+
+
+
+
+
+
+ false
+ true
+
+
+
+
+
+
+
+
+
+
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',').Length)
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[4])
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[5])
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[6])
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[7])
+
+
+ %(PaketReferencesFileLinesInfo.PackageVersion)
+ All
+ runtime
+ $(ExcludeAssets);contentFiles
+ $(ExcludeAssets);build;buildMultitargeting;buildTransitive
+ true
+ true
+
+
+
+
+ $(PaketIntermediateOutputPath)/$(MSBuildProjectFile).paket.clitools
+
+
+
+
+
+
+
+
+ $([System.String]::Copy('%(PaketCliToolFileLines.Identity)').Split(',')[0])
+ $([System.String]::Copy('%(PaketCliToolFileLines.Identity)').Split(',')[1])
+
+
+ %(PaketCliToolFileLinesInfo.PackageVersion)
+
+
+
+
-
-
-
-
- false
-
-
-
-
-
- <_NuspecFilesNewLocation Include="$(PaketIntermediateOutputPath)\$(Configuration)\*.nuspec"/>
-
-
-
-
-
- $(MSBuildProjectDirectory)/$(MSBuildProjectFile)
- true
- false
- true
- false
- true
- false
- true
- false
- true
- false
- true
- $(PaketIntermediateOutputPath)\$(Configuration)
- $(PaketIntermediateOutputPath)
-
-
-
- <_NuspecFiles Include="$(AdjustedNuspecOutputPath)\*.$(PackageVersion.Split(`+`)[0]).nuspec"/>
-
-
-
-
-
-
-
-
-
+
+
+
+
+ false
+
+
+
+
+
+ <_NuspecFilesNewLocation Include="$(PaketIntermediateOutputPath)\$(Configuration)\*.nuspec"/>
+
+
+
+
+
+ $(MSBuildProjectDirectory)/$(MSBuildProjectFile)
+ true
+ false
+ true
+ false
+ true
+ false
+ true
+ false
+ true
+ false
+ true
+ $(PaketIntermediateOutputPath)\$(Configuration)
+ $(PaketIntermediateOutputPath)
+
+
+
+ <_NuspecFiles Include="$(AdjustedNuspecOutputPath)\*.$(PackageVersion.Split(`+`)[0]).nuspec"/>
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/integrationtests/Paket.IntegrationTests/ConditionSpecs.fs b/integrationtests/Paket.IntegrationTests/ConditionSpecs.fs
new file mode 100644
index 0000000000..ee87ae6c8f
--- /dev/null
+++ b/integrationtests/Paket.IntegrationTests/ConditionSpecs.fs
@@ -0,0 +1,237 @@
+module Paket.IntegrationTests.ConditionSpecs
+
+open System.Text.RegularExpressions
+open System.Xml.Linq
+open System.Xml.XPath
+open Fake
+open System
+open NUnit.Framework
+open FsUnit
+open System
+open System.IO
+open System.Diagnostics
+open Paket
+open Paket.Domain
+
+let preparePackages workingDir =
+ let packagesDir = workingDir @@ "Packages"
+
+ [1..5]
+ |> List.filter (fun v -> fileExists (workingDir @@ "Packages" @@ $"PaketTest2394.PackageA.%d{v}.0.0.nupkg") |> not)
+ |> List.map (fun v -> directDotnet false $"pack -o . -p:Version=%d{v}.0" packagesDir)
+ |> ignore
+
+let prepareBuildProps projectDir =
+ let propsFile = (projectDir @@ "Directory.Build.props")
+ let xmlDoc = XDocument.Load propsFile
+ let propertyGroup = xmlDoc.Descendants("PropertyGroup")
+ |> Seq.head
+ propertyGroup.Add(XElement("PaketExePath", paketToolPath |> snd))
+ xmlDoc.Save propsFile
+
+let dotnetRun projectDir project configuration =
+ match configuration with
+ | Some config -> directDotnet false $"run --project %s{project} --configuration %s{config}" projectDir
+ | None -> directDotnet false $"run --project %s{project}" projectDir
+ |> Seq.map (_.Message)
+
+let dotnetPack projectDir project configuration =
+ match configuration with
+ | Some config -> directDotnet false $"pack %s{project} --configuration %s{config} -o ." projectDir
+ | None -> directDotnet false $"pack %s{project} -o ." projectDir
+ |> ignore
+
+let private shouldIncludeVersionedString (pattern: string) (version: int) (inputs: string seq) =
+ let expected = pattern.Replace("XX", version.ToString())
+ let regex = $"""^%s{Regex.Escape(pattern).Replace("XX", "(\d)")}$"""
+
+ inputs
+ |> Seq.filter (fun input -> Regex.IsMatch(input, regex))
+ |> Seq.iter (fun input -> Assert.That(input, Is.EqualTo expected))
+
+let private shouldIncludePackageA v i = shouldIncludeVersionedString "PackageA XX.0" v i
+let private shouldIncludePackageB v i = shouldIncludeVersionedString "PackageB XX.0 (references PackageB.Transient XX.0)" v i
+let private shouldIncludePackageBTransient v i = shouldIncludeVersionedString "PackageB.Transient XX.0" v i
+let private shouldIncludeConstant v i = shouldIncludeVersionedString "Constant PACKAGEA_XX set" v i
+
+[]
+let ``#2394 default group with no condition`` () =
+ let scenario = "i002394-group-conditions"
+ preparePackages (originalScenarioPath scenario)
+
+ use __ = prepare scenario
+ let root = scenarioTempPath scenario
+ let projectDir = root @@ "TestProjects"
+ prepareBuildProps projectDir
+
+ directPaketInPath "install" projectDir |> ignore
+ let output = dotnetRun projectDir "MainGroup.fsproj" None
+ dotnetPack projectDir "MainGroup.fsproj" None
+
+ output |> shouldIncludePackageA 1
+ output |> shouldIncludePackageB 1
+ output |> shouldIncludePackageBTransient 1
+ output |> shouldIncludeConstant 1
+
+ let nupkgPath = projectDir @@ "MainGroup.1.0.0.nupkg"
+
+ if File.Exists nupkgPath |> not then Assert.Fail $"Expected '%s{nupkgPath}' to exist"
+ let nuspec = NuGetCache.getNuSpecFromNupkg nupkgPath
+ let dependencies = nuspec.Dependencies.Value
+ |> List.map (fun (n, v, _) -> n.Name, v.Range.ToString())
+
+ let expected = [("PaketTest2394.PackageA", ">= 1.0 < 2.0"); ("PaketTest2394.PackageB", ">= 1.0 < 2.0")]
+ Assert.That(dependencies, Is.SupersetOf expected)
+
+[]
+let ``#2394 alternate group with no condition`` () =
+ let scenario = "i002394-group-conditions"
+ preparePackages (originalScenarioPath scenario)
+
+ use __ = prepare scenario
+ let root = scenarioTempPath scenario
+ let projectDir = root @@ "TestProjects"
+ prepareBuildProps projectDir
+
+ directPaketInPath "install" projectDir |> ignore
+ let output = dotnetRun projectDir "NonConditionalGroup.fsproj" None
+ dotnetPack projectDir "NonConditionalGroup.fsproj" None
+
+ output |> shouldIncludePackageA 2
+ output |> shouldIncludePackageB 2
+ output |> shouldIncludePackageBTransient 2
+ output |> shouldIncludeConstant 2
+
+ let nupkgPath = projectDir @@ "NonConditionalGroup.1.0.0.nupkg"
+
+ if File.Exists nupkgPath |> not then Assert.Fail $"Expected '%s{nupkgPath}' to exist"
+ let nuspec = NuGetCache.getNuSpecFromNupkg nupkgPath
+ let dependencies = nuspec.Dependencies.Value
+ |> List.map (fun (n, v, _) -> n.Name, v.Range.ToString())
+
+ let expected = [("PaketTest2394.PackageA", ">= 2.0 < 3.0"); ("PaketTest2394.PackageB", ">= 2.0 < 3.0")]
+ Assert.That(dependencies, Is.SupersetOf expected)
+
+[]
+let ``#2394 group with fixed property condition`` () =
+ let scenario = "i002394-group-conditions"
+ preparePackages (originalScenarioPath scenario)
+
+ use __ = prepare scenario
+ let root = scenarioTempPath scenario
+ let projectDir = root @@ "TestProjects"
+ prepareBuildProps projectDir
+
+ directPaketInPath "install" projectDir |> ignore
+ let output = dotnetRun projectDir "FixedProperty.fsproj" None
+ dotnetPack projectDir "FixedProperty.fsproj" None
+
+ output |> shouldIncludePackageA 3
+ output |> shouldIncludePackageB 3
+ output |> shouldIncludePackageBTransient 3
+ output |> shouldIncludeConstant 3
+
+ let nupkgPath = projectDir @@ "FixedProperty.1.0.0.nupkg"
+
+ if File.Exists nupkgPath |> not then Assert.Fail $"Expected '%s{nupkgPath}' to exist"
+ let nuspec = NuGetCache.getNuSpecFromNupkg nupkgPath
+ let dependencies = nuspec.Dependencies.Value
+ |> List.map (fun (n, v, _) -> n.Name, v.Range.ToString())
+
+ let expected = [("PaketTest2394.PackageA", ">= 3.0 < 4.0"); ("PaketTest2394.PackageB", ">= 3.0 < 4.0")]
+ Assert.That(dependencies, Is.SupersetOf expected)
+
+[]
+let ``#2394 mix dependencies from multiple groups with conditions`` () =
+ let scenario = "i002394-group-conditions"
+ preparePackages (originalScenarioPath scenario)
+
+ use __ = prepare scenario
+ let root = scenarioTempPath scenario
+ let projectDir = root @@ "TestProjects"
+ prepareBuildProps projectDir
+
+ directPaketInPath "install" projectDir |> ignore
+ let output = dotnetRun projectDir "MixedProperties.fsproj" None
+ dotnetPack projectDir "MixedProperties.fsproj" None
+
+ output |> shouldIncludePackageA 4
+ output |> shouldIncludePackageB 5
+ output |> shouldIncludePackageBTransient 5
+ output |> shouldIncludeConstant 4
+
+ let expected = ["PackageA 4.0"; "PackageB 5.0 (references PackageB.Transient 5.0)"; "PackageB.Transient 5.0"; "Constant PACKAGEA_4 set"]
+ let rejected = ["PackageA 1.0"; "PackageB.Transient 1.0"; "Constant PACKAGEA_1 set"
+ "PackageA 2.0"; "PackageB.Transient 2.0"; "Constant PACKAGEA_2 set"
+ "PackageA 3.0"; "PackageB.Transient 3.0"; "Constant PACKAGEA_3 set"
+ "PackageA 5.0"; "PackageB.Transient 4.0"; "Constant PACKAGEA_5 set"]
+ Assert.That(output, Is.SupersetOf expected)
+ Assert.That(output, Is.Not.SubsetOf rejected)
+
+ let nupkgPath = projectDir @@ "MixedProperties.1.0.0.nupkg"
+
+ if File.Exists nupkgPath |> not then Assert.Fail $"Expected '%s{nupkgPath}' to exist"
+ let nuspec = NuGetCache.getNuSpecFromNupkg nupkgPath
+ let dependencies = nuspec.Dependencies.Value
+ |> List.map (fun (n, v, _) -> n.Name, v.Range.ToString())
+
+ let expected = [("PaketTest2394.PackageA", ">= 4.0 < 5.0"); ("PaketTest2394.PackageB", ">= 5.0 < 6.0")]
+ Assert.That(dependencies, Is.SupersetOf expected)
+
+[]
+let ``#2394 project with dynamic condition based on configuration 1`` () =
+ let scenario = "i002394-group-conditions"
+ preparePackages (originalScenarioPath scenario)
+
+ use __ = prepare scenario
+ let root = scenarioTempPath scenario
+ let projectDir = root @@ "TestProjects"
+ prepareBuildProps projectDir
+
+ directPaketInPath "install" projectDir |> ignore
+ let output = dotnetRun projectDir "ConfigurationDependent.fsproj" None
+ dotnetPack projectDir "ConfigurationDependent.fsproj" None
+
+ output |> shouldIncludePackageA 3
+ output |> shouldIncludePackageB 3
+ output |> shouldIncludePackageBTransient 3
+ output |> shouldIncludeConstant 3
+
+ let nupkgPath = projectDir @@ "ConfigurationDependent.1.0.0.nupkg"
+
+ if File.Exists nupkgPath |> not then Assert.Fail $"Expected '%s{nupkgPath}' to exist"
+ let nuspec = NuGetCache.getNuSpecFromNupkg nupkgPath
+ let dependencies = nuspec.Dependencies.Value
+ |> List.map (fun (n, v, _) -> n.Name, v.Range.ToString())
+
+ let expected = [("PaketTest2394.PackageA", ">= 3.0 < 4.0"); ("PaketTest2394.PackageB", ">= 3.0 < 4.0")]
+ Assert.That(dependencies, Is.SupersetOf expected)
+
+[]
+let ``#2394 project with dynamic condition based on configuration 2`` () =
+ let scenario = "i002394-group-conditions"
+ preparePackages (originalScenarioPath scenario)
+
+ use __ = prepare scenario
+ let root = scenarioTempPath scenario
+ let projectDir = root @@ "TestProjects"
+ prepareBuildProps projectDir
+
+ directPaketInPath "install" projectDir |> ignore
+ let output = dotnetRun projectDir "ConfigurationDependent.fsproj" (Some "Alternate")
+ dotnetPack projectDir "ConfigurationDependent.fsproj" (Some "Alternate")
+
+ output |> shouldIncludePackageA 4
+ output |> shouldIncludePackageB 4
+ output |> shouldIncludePackageBTransient 4
+ output |> shouldIncludeConstant 4
+
+ let nupkgPath = projectDir @@ "ConfigurationDependent.1.0.0.nupkg"
+
+ if File.Exists nupkgPath |> not then Assert.Fail $"Expected '%s{nupkgPath}' to exist"
+ let nuspec = NuGetCache.getNuSpecFromNupkg nupkgPath
+ let dependencies = nuspec.Dependencies.Value
+ |> List.map (fun (n, v, _) -> n.Name, v.Range.ToString())
+
+ let expected = [("PaketTest2394.PackageA", ">= 4.0 < 5.0"); ("PaketTest2394.PackageB", ">= 4.0 < 5.0")]
+ Assert.That(dependencies, Is.SupersetOf expected)
diff --git a/integrationtests/Paket.IntegrationTests/Paket.IntegrationTests.fsproj b/integrationtests/Paket.IntegrationTests/Paket.IntegrationTests.fsproj
index f134ed92c0..641146eec4 100644
--- a/integrationtests/Paket.IntegrationTests/Paket.IntegrationTests.fsproj
+++ b/integrationtests/Paket.IntegrationTests/Paket.IntegrationTests.fsproj
@@ -40,6 +40,7 @@
+
@@ -51,4 +52,4 @@
-
\ No newline at end of file
+
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/.gitignore b/integrationtests/scenarios/i002394-group-conditions/before/.gitignore
new file mode 100644
index 0000000000..09417ada6d
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/.gitignore
@@ -0,0 +1,2 @@
+*.nupkg
+bin/
\ No newline at end of file
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/Packages/Directory.Build.targets b/integrationtests/scenarios/i002394-group-conditions/before/Packages/Directory.Build.targets
new file mode 100644
index 0000000000..11cd321c71
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/Packages/Directory.Build.targets
@@ -0,0 +1,17 @@
+
+
+
+
+ <_ProjectReferenceWithExplicitPackageVersion Include="@(ProjectReference->'%(FullPath)')" Condition="'%(ProjectReference.PackageVersion)' != ''" />
+ <_ProjectReferenceWithExactPackageVersion Include="@(ProjectReference->'%(FullPath)')" />
+ <_ProjectReferenceWithReassignedVersion Include="@(_ProjectReferencesWithVersions)" Condition="'%(Identity)' != '' And '@(_ProjectReferenceWithExplicitPackageVersion)' == '@(_ProjectReferencesWithVersions)'">
+ @(_ProjectReferenceWithExplicitPackageVersion->'%(PackageVersion)')
+
+ <_ProjectReferenceWithReassignedVersion Include="@(_ProjectReferencesWithVersions)" Condition="'%(Identity)' != '' And '@(_ProjectReferenceWithExactPackageVersion)' == '@(_ProjectReferencesWithVersions)'">
+ [@(_ProjectReferencesWithVersions->'%(ProjectVersion)')]
+
+ <_ProjectReferencesWithVersions Remove="@(_ProjectReferenceWithReassignedVersion)" />
+ <_ProjectReferencesWithVersions Include="@(_ProjectReferenceWithReassignedVersion)" />
+
+
+
\ No newline at end of file
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/Packages/Packages.sln b/integrationtests/scenarios/i002394-group-conditions/before/Packages/Packages.sln
new file mode 100644
index 0000000000..45e37625f2
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/Packages/Packages.sln
@@ -0,0 +1,28 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PaketTest2394.PackageA", "PaketTest2394.PackageA\PaketTest2394.PackageA.csproj", "{A0449AB0-A1EA-4BE6-8D03-701BC5A2FD46}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PaketTest2394.PackageB", "PaketTest2394.PackageB\PaketTest2394.PackageB.csproj", "{59B3FFCE-AA5A-4AAA-B73D-108A6A15E524}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PaketTest2394.PackageB.Transient", "PaketTest2394.PackageB.Transient\PaketTest2394.PackageB.Transient.csproj", "{C763B8F6-18BF-4018-B852-CA8EE39C94F5}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {A0449AB0-A1EA-4BE6-8D03-701BC5A2FD46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A0449AB0-A1EA-4BE6-8D03-701BC5A2FD46}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A0449AB0-A1EA-4BE6-8D03-701BC5A2FD46}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A0449AB0-A1EA-4BE6-8D03-701BC5A2FD46}.Release|Any CPU.Build.0 = Release|Any CPU
+ {59B3FFCE-AA5A-4AAA-B73D-108A6A15E524}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {59B3FFCE-AA5A-4AAA-B73D-108A6A15E524}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {59B3FFCE-AA5A-4AAA-B73D-108A6A15E524}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {59B3FFCE-AA5A-4AAA-B73D-108A6A15E524}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C763B8F6-18BF-4018-B852-CA8EE39C94F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C763B8F6-18BF-4018-B852-CA8EE39C94F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C763B8F6-18BF-4018-B852-CA8EE39C94F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C763B8F6-18BF-4018-B852-CA8EE39C94F5}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+EndGlobal
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageA/PackageDescription.cs b/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageA/PackageDescription.cs
new file mode 100644
index 0000000000..22278a36b3
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageA/PackageDescription.cs
@@ -0,0 +1,10 @@
+namespace PaketTest2394.PackageA;
+
+public static class PackageDescription
+{
+ public static string GetDescription()
+ {
+ var assemblyName = typeof(PackageDescription).Assembly.GetName();
+ return $"PackageA {assemblyName.Version!.ToString(2)}";
+ }
+}
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageA/PaketTest2394.PackageA.csproj b/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageA/PaketTest2394.PackageA.csproj
new file mode 100644
index 0000000000..17e138c0ea
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageA/PaketTest2394.PackageA.csproj
@@ -0,0 +1,17 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+ %24(DefineConstants)%3BPACKAGEA_$(Version.Split('.')[0])
+
+
+
+
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageA/build/PaketTest2394.PackageA.targets b/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageA/build/PaketTest2394.PackageA.targets
new file mode 100644
index 0000000000..0e0fe5b3aa
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageA/build/PaketTest2394.PackageA.targets
@@ -0,0 +1,5 @@
+
+
+ $(DefineConstants);PACKAGEA_5
+
+
\ No newline at end of file
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageB.Transient/PackageDescription.cs b/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageB.Transient/PackageDescription.cs
new file mode 100644
index 0000000000..3f26273206
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageB.Transient/PackageDescription.cs
@@ -0,0 +1,10 @@
+namespace PaketTest2394.PackageB.Transient;
+
+public static class PackageDescription
+{
+ public static string GetDescription()
+ {
+ var assemblyName = typeof(PackageDescription).Assembly.GetName();
+ return $"PackageB.Transient {assemblyName.Version!.ToString(2)}";
+ }
+}
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageB.Transient/PaketTest2394.PackageB.Transient.csproj b/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageB.Transient/PaketTest2394.PackageB.Transient.csproj
new file mode 100644
index 0000000000..8a9183198f
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageB.Transient/PaketTest2394.PackageB.Transient.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageB/PackageDescription.cs b/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageB/PackageDescription.cs
new file mode 100644
index 0000000000..5cf468a8d4
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageB/PackageDescription.cs
@@ -0,0 +1,10 @@
+namespace PaketTest2394.PackageB;
+
+public static class PackageDescription
+{
+ public static string GetDescription()
+ {
+ var assemblyName = typeof(PackageDescription).Assembly.GetName();
+ return $"PackageB {assemblyName.Version!.ToString(2)} (references {Transient.PackageDescription.GetDescription()})";
+ }
+}
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageB/PaketTest2394.PackageB.csproj b/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageB/PaketTest2394.PackageB.csproj
new file mode 100644
index 0000000000..0b7db6e071
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/Packages/PaketTest2394.PackageB/PaketTest2394.PackageB.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/.paket/Paket.Restore.targets b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/.paket/Paket.Restore.targets
new file mode 100644
index 0000000000..0749ac7968
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/.paket/Paket.Restore.targets
@@ -0,0 +1,570 @@
+
+
+
+
+
+
+ $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
+
+ $(MSBuildVersion)
+ 15.0.0
+ false
+ true
+
+ true
+ $(MSBuildThisFileDirectory)
+ $(MSBuildThisFileDirectory)..\
+ $(PaketRootPath)paket-files\paket.restore.cached
+ $(PaketRootPath)paket.lock
+ classic
+ proj
+ assembly
+ native
+ /Library/Frameworks/Mono.framework/Commands/mono
+ mono
+
+
+ $(PaketRootPath)paket.bootstrapper.exe
+ $(PaketToolsPath)paket.bootstrapper.exe
+ $([System.IO.Path]::GetDirectoryName("$(PaketBootStrapperExePath)"))\
+
+ "$(PaketBootStrapperExePath)"
+ $(MonoPath) --runtime=v4.0.30319 "$(PaketBootStrapperExePath)"
+
+
+
+
+ true
+ true
+
+
+ True
+
+
+ False
+
+ $(BaseIntermediateOutputPath.TrimEnd('\').TrimEnd('\/'))
+
+
+
+
+
+
+
+
+ $(PaketRootPath)paket
+ $(PaketToolsPath)paket
+
+
+
+
+
+ $(PaketRootPath)paket.exe
+ $(PaketToolsPath)paket.exe
+
+
+
+
+
+ <_DotnetToolsJson Condition="Exists('$(PaketRootPath)/.config/dotnet-tools.json')">$([System.IO.File]::ReadAllText("$(PaketRootPath)/.config/dotnet-tools.json"))
+ <_ConfigContainsPaket Condition=" '$(_DotnetToolsJson)' != ''">$(_DotnetToolsJson.Contains('"paket"'))
+ <_ConfigContainsPaket Condition=" '$(_ConfigContainsPaket)' == ''">false
+
+
+
+
+
+
+
+
+
+
+ <_PaketCommand>dotnet paket
+
+
+
+
+
+ $(PaketToolsPath)paket
+ $(PaketBootStrapperExeDir)paket
+
+
+ paket
+
+
+
+
+ <_PaketExeExtension>$([System.IO.Path]::GetExtension("$(PaketExePath)"))
+ <_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(_PaketExeExtension)' == '.dll' ">dotnet "$(PaketExePath)"
+ <_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(OS)' != 'Windows_NT' AND '$(_PaketExeExtension)' == '.exe' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"
+ <_PaketCommand Condition=" '$(_PaketCommand)' == '' ">"$(PaketExePath)"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ $(NoWarn);NU1603;NU1604;NU1605;NU1608
+ false
+ true
+
+
+
+
+
+
+
+
+ $([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)'))
+
+
+
+
+
+
+ $([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`)[0].Replace(`"`, ``).Replace(` `, ``))
+ $([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`)[1].Replace(`"`, ``).Replace(` `, ``))
+
+
+
+
+ %(PaketRestoreCachedKeyValue.Value)
+ %(PaketRestoreCachedKeyValue.Value)
+
+
+
+
+ true
+ false
+ true
+
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(PaketIntermediateOutputPath)\$(MSBuildProjectFile).paket.references.cached
+
+ $(MSBuildProjectFullPath).paket.references
+
+ $(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references
+
+ $(MSBuildProjectDirectory)\paket.references
+
+ false
+ true
+ true
+ references-file-or-cache-not-found
+
+
+
+
+ $([System.IO.File]::ReadAllText('$(PaketReferencesCachedFilePath)'))
+ $([System.IO.File]::ReadAllText('$(PaketOriginalReferencesFilePath)'))
+ references-file
+ false
+
+
+
+
+ false
+
+
+
+
+ true
+ target-framework '$(TargetFramework)' or '$(TargetFrameworks)' files @(PaketResolvedFilePaths)
+
+
+
+
+
+
+
+
+
+
+ false
+ true
+
+
+
+
+
+
+
+
+
+
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',').Length)
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[4])
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[5])
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[6])
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[7])
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[8])
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[9])
+
+
+ %(PaketReferencesFileLinesInfo.PackageVersion)
+ All
+ runtime
+ $(ExcludeAssets);contentFiles
+ $(ExcludeAssets);build;buildMultitargeting;buildTransitive
+ %(PaketReferencesFileLinesInfo.Aliases)
+ true
+ true
+
+
+
+
+ $(PaketIntermediateOutputPath)/$(MSBuildProjectFile).paket.clitools
+
+
+
+
+
+
+
+
+ $([System.String]::Copy('%(PaketCliToolFileLines.Identity)').Split(',')[0])
+ $([System.String]::Copy('%(PaketCliToolFileLines.Identity)').Split(',')[1])
+
+
+ %(PaketCliToolFileLinesInfo.PackageVersion)
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+ <_NuspecFilesNewLocation Include="$(PaketIntermediateOutputPath)\$(Configuration)\*.nuspec"/>
+
+
+
+
+
+ $(MSBuildProjectDirectory)/$(MSBuildProjectFile)
+ true
+ false
+ true
+ false
+ true
+ false
+ true
+ false
+ true
+ false
+ true
+ $(PaketIntermediateOutputPath)\$(Configuration)
+ $(PaketIntermediateOutputPath)
+
+
+
+ <_NuspecFiles Include="$(AdjustedNuspecOutputPath)\*.$(PackageVersion.Split(`+`)[0]).nuspec"/>
+
+
+
+
+
+
+
+ <_DefinedConditionProperties Include="@(_ConditionProperties)" Condition="$(%(Identity)) == 'true'"/>
+
+
+ <_ConditionsParameter>
+ <_ConditionsParameter Condition="@(_DefinedConditionProperties) != ''">--conditions @(_DefinedConditionProperties)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/ConfigurationDependent.fsproj b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/ConfigurationDependent.fsproj
new file mode 100644
index 0000000000..c96e004674
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/ConfigurationDependent.fsproj
@@ -0,0 +1,14 @@
+
+
+
+ Exe
+ net8.0
+ Debug;Release;Alternate
+ true
+ true
+
+
+
+
+
+
\ No newline at end of file
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/ConfigurationDependent.fsproj.paket.references b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/ConfigurationDependent.fsproj.paket.references
new file mode 100644
index 0000000000..9eea92382a
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/ConfigurationDependent.fsproj.paket.references
@@ -0,0 +1,9 @@
+FSharp.Core
+
+group condition-x
+ PaketTest2394.PackageA
+ PaketTest2394.PackageB
+
+group condition-y
+ PaketTest2394.PackageA
+ PaketTest2394.PackageB
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/Directory.Build.props b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/Directory.Build.props
new file mode 100644
index 0000000000..5dc225d133
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/Directory.Build.props
@@ -0,0 +1,6 @@
+
+
+ bin/$(MSBuildProjectName)/$(Configuration)
+ obj/$(MSBuildProjectName)/$(Configuration)
+
+
\ No newline at end of file
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/FixedProperty.fsproj b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/FixedProperty.fsproj
new file mode 100644
index 0000000000..1c3e4f6726
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/FixedProperty.fsproj
@@ -0,0 +1,12 @@
+
+
+
+ Exe
+ net8.0
+ true
+
+
+
+
+
+
\ No newline at end of file
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/FixedProperty.fsproj.paket.references b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/FixedProperty.fsproj.paket.references
new file mode 100644
index 0000000000..9eea92382a
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/FixedProperty.fsproj.paket.references
@@ -0,0 +1,9 @@
+FSharp.Core
+
+group condition-x
+ PaketTest2394.PackageA
+ PaketTest2394.PackageB
+
+group condition-y
+ PaketTest2394.PackageA
+ PaketTest2394.PackageB
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/MainGroup.fsproj b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/MainGroup.fsproj
new file mode 100644
index 0000000000..733205dc98
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/MainGroup.fsproj
@@ -0,0 +1,12 @@
+
+
+
+ Exe
+ net8.0
+ true
+
+
+
+
+
+
\ No newline at end of file
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/MainGroup.fsproj.paket.references b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/MainGroup.fsproj.paket.references
new file mode 100644
index 0000000000..3da58c9656
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/MainGroup.fsproj.paket.references
@@ -0,0 +1,4 @@
+FSharp.Core
+
+PaketTest2394.PackageA
+PaketTest2394.PackageB
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/MixedProperties.fsproj b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/MixedProperties.fsproj
new file mode 100644
index 0000000000..d1b99245a5
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/MixedProperties.fsproj
@@ -0,0 +1,13 @@
+
+
+
+ Exe
+ net8.0
+ true
+ true
+
+
+
+
+
+
\ No newline at end of file
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/MixedProperties.fsproj.paket.references b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/MixedProperties.fsproj.paket.references
new file mode 100644
index 0000000000..0b359ab2fe
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/MixedProperties.fsproj.paket.references
@@ -0,0 +1,11 @@
+FSharp.Core
+
+group condition-x
+ PaketTest2394.PackageA
+ PaketTest2394.PackageB
+
+group condition-y
+ PaketTest2394.PackageA
+
+group condition-z
+ PaketTest2394.PackageB
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/NonConditionalGroup.fsproj b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/NonConditionalGroup.fsproj
new file mode 100644
index 0000000000..0aadb1bf76
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/NonConditionalGroup.fsproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net8.0
+
+
+
+
+
+
\ No newline at end of file
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/NonConditionalGroup.fsproj.paket.references b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/NonConditionalGroup.fsproj.paket.references
new file mode 100644
index 0000000000..d4841182b9
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/NonConditionalGroup.fsproj.paket.references
@@ -0,0 +1,5 @@
+FSharp.Core
+
+group no-condition
+ PaketTest2394.PackageA
+ PaketTest2394.PackageB
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/Program.fs b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/Program.fs
new file mode 100644
index 0000000000..8b03e7923b
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/Program.fs
@@ -0,0 +1,21 @@
+// To verify versions of referenced packages
+printfn "%s" (PaketTest2394.PackageA.PackageDescription.GetDescription())
+printfn "%s" (PaketTest2394.PackageB.PackageDescription.GetDescription())
+printfn "%s" (PaketTest2394.PackageB.Transient.PackageDescription.GetDescription())
+
+// To verify that *.targets file is loaded from the correct package version
+#if PACKAGEA_1
+printfn "Constant PACKAGEA_1 set"
+#endif
+#if PACKAGEA_2
+printfn "Constant PACKAGEA_2 set"
+#endif
+#if PACKAGEA_3
+printfn "Constant PACKAGEA_3 set"
+#endif
+#if PACKAGEA_4
+printfn "Constant PACKAGEA_4 set"
+#endif
+#if PACKAGEA_5
+printfn "Constant PACKAGEA_5 set"
+#endif
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/TestProjects.sln b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/TestProjects.sln
new file mode 100644
index 0000000000..5678045ab0
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/TestProjects.sln
@@ -0,0 +1,40 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "MainGroup", "MainGroup.fsproj", "{D5F04B31-1026-4F46-A75D-7F0989F73364}"
+EndProject
+Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "NonConditionalGroup", "NonConditionalGroup.fsproj", "{D43053B0-6860-454A-B42B-617B83514B3A}"
+EndProject
+Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FixedProperty", "FixedProperty.fsproj", "{5A5E1C52-7626-40C1-8522-24FA71826D46}"
+EndProject
+Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "MixedProperties", "MixedProperties.fsproj", "{E6290682-7B89-4E1F-A282-3B8545F2DBFC}"
+EndProject
+Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "ConfigurationDependent", "ConfigurationDependent.fsproj", "{6CC1CEA1-9F9A-4F8D-84C8-B5837391A114}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {D5F04B31-1026-4F46-A75D-7F0989F73364}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D5F04B31-1026-4F46-A75D-7F0989F73364}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D5F04B31-1026-4F46-A75D-7F0989F73364}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D5F04B31-1026-4F46-A75D-7F0989F73364}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D43053B0-6860-454A-B42B-617B83514B3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D43053B0-6860-454A-B42B-617B83514B3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D43053B0-6860-454A-B42B-617B83514B3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D43053B0-6860-454A-B42B-617B83514B3A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5A5E1C52-7626-40C1-8522-24FA71826D46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5A5E1C52-7626-40C1-8522-24FA71826D46}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5A5E1C52-7626-40C1-8522-24FA71826D46}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5A5E1C52-7626-40C1-8522-24FA71826D46}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E6290682-7B89-4E1F-A282-3B8545F2DBFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E6290682-7B89-4E1F-A282-3B8545F2DBFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E6290682-7B89-4E1F-A282-3B8545F2DBFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E6290682-7B89-4E1F-A282-3B8545F2DBFC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6CC1CEA1-9F9A-4F8D-84C8-B5837391A114}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6CC1CEA1-9F9A-4F8D-84C8-B5837391A114}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6CC1CEA1-9F9A-4F8D-84C8-B5837391A114}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6CC1CEA1-9F9A-4F8D-84C8-B5837391A114}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+EndGlobal
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/paket.dependencies b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/paket.dependencies
new file mode 100644
index 0000000000..01f45aa608
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/paket.dependencies
@@ -0,0 +1,41 @@
+source https://api.nuget.org/v3/index.json
+source ../Packages
+
+nuget FSharp.Core
+
+nuget PaketTest2394.PackageA ~> 1.0
+nuget PaketTest2394.PackageB ~> 1.0
+
+group no-condition
+ source https://api.nuget.org/v3/index.json
+ source ../Packages
+
+ nuget PaketTest2394.PackageA ~> 2.0
+ nuget PaketTest2394.PackageB ~> 2.0
+
+group condition-x
+ condition PropertyX
+
+ source https://api.nuget.org/v3/index.json
+ source ../Packages
+
+ nuget PaketTest2394.PackageA ~> 3.0
+ nuget PaketTest2394.PackageB ~> 3.0
+
+group condition-y
+ condition PropertyY
+
+ source https://api.nuget.org/v3/index.json
+ source ../Packages
+
+ nuget PaketTest2394.PackageA ~> 4.0
+ nuget PaketTest2394.PackageB ~> 4.0
+
+group condition-z
+ condition PropertyZ
+
+ source https://api.nuget.org/v3/index.json
+ source ../Packages
+
+ nuget PaketTest2394.PackageB ~> 5.0
+
diff --git a/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/paket.lock b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/paket.lock
new file mode 100644
index 0000000000..a77270da33
--- /dev/null
+++ b/integrationtests/scenarios/i002394-group-conditions/before/TestProjects/paket.lock
@@ -0,0 +1,42 @@
+NUGET
+ remote: https://api.nuget.org/v3/index.json
+ FSharp.Core (8.0.200)
+ remote: ../Packages
+ PaketTest2394.PackageA (1.0.0)
+ PaketTest2394.PackageB (1.0.0)
+ PaketTest2394.PackageB.Transient (1.0) - restriction: >= net6.0
+ PaketTest2394.PackageB.Transient (1.0.0) - restriction: >= net6.0
+
+GROUP condition-x
+CONDITION: PROPERTYX
+NUGET
+ remote: ../Packages
+ PaketTest2394.PackageA (3.0.0)
+ PaketTest2394.PackageB (3.0.0)
+ PaketTest2394.PackageB.Transient (3.0) - restriction: >= net6.0
+ PaketTest2394.PackageB.Transient (3.0.0) - restriction: >= net6.0
+
+GROUP condition-y
+CONDITION: PROPERTYY
+NUGET
+ remote: ../Packages
+ PaketTest2394.PackageA (4.0.0)
+ PaketTest2394.PackageB (4.0.0)
+ PaketTest2394.PackageB.Transient (4.0) - restriction: >= net6.0
+ PaketTest2394.PackageB.Transient (4.0.0) - restriction: >= net6.0
+
+GROUP condition-z
+CONDITION: PROPERTYZ
+NUGET
+ remote: ../Packages
+ PaketTest2394.PackageB (5.0.0)
+ PaketTest2394.PackageB.Transient (5.0) - restriction: >= net6.0
+ PaketTest2394.PackageB.Transient (5.0.0) - restriction: >= net6.0
+
+GROUP no-condition
+NUGET
+ remote: ../Packages
+ PaketTest2394.PackageA (2.0.0)
+ PaketTest2394.PackageB (2.0.0)
+ PaketTest2394.PackageB.Transient (2.0) - restriction: >= net6.0
+ PaketTest2394.PackageB.Transient (2.0.0) - restriction: >= net6.0
diff --git a/src/Paket.Core/Installation/RestoreProcess.fs b/src/Paket.Core/Installation/RestoreProcess.fs
index 972eb5bbf3..2936f10bbd 100644
--- a/src/Paket.Core/Installation/RestoreProcess.fs
+++ b/src/Paket.Core/Installation/RestoreProcess.fs
@@ -314,20 +314,22 @@ let createPaketPropsFile (lockFile:LockFile) (cliTools:ResolvedPackage seq) (pac
| ExplicitRestriction fw -> ExplicitRestriction fw
| _ -> group.Options.Settings.FrameworkRestrictions
let condition = getExplicitRestriction restrictions
- p,condition,packageSettings)
- |> Seq.groupBy (fun (_,c,__) -> c)
- |> Seq.collect (fun (condition,packages) ->
- let condition =
+
+ p,condition,packageSettings,group.Options.Settings.ReferenceCondition)
+ |> Seq.groupBy (fun (_,c,__,rc) -> c,rc)
+ |> Seq.collect (fun ((condition,referenceCondition),packages) ->
+ let targets =
match condition with
- | FrameworkRestriction.HasNoRestriction -> ""
- | restrictions -> restrictions.ToMSBuildCondition()
+ | FrameworkRestriction.HasNoRestriction -> Set.empty
+ | restrictions -> restrictions.RepresentedFrameworks
+ let condition = PlatformMatching.getCondition referenceCondition targets
let condition =
if condition = "" || condition = "true" then "" else
sprintf " AND (%s)" condition
let packageReferences =
packages
- |> Seq.collect (fun (p,_,packageSettings) ->
+ |> Seq.collect (fun (p,_,packageSettings,__) ->
[yield sprintf """ """ p.Name
yield sprintf """ %O""" p.Version
let excludeAssets =
@@ -447,6 +449,7 @@ let createProjectReferencesFiles (lockFile:LockFile) (projectFile:ProjectFile) (
let combinedOmitContent = combineOmitContent resolvedPackage.Settings packageSettings
let combinedImportTargets = combineImportTargets resolvedPackage.Settings packageSettings
let aliases = if direct then packageSettings.Settings.Aliases |> Seq.tryHead else None
+ let condition = kv.Value.Options.Settings.ReferenceCondition |> Option.defaultValue "true"
let privateAssetsAll =
match combinedCopyLocal with
@@ -481,7 +484,8 @@ let createProjectReferencesFiles (lockFile:LockFile) (projectFile:ProjectFile) (
copyLocal
omitContent
importTargets
- alias]
+ alias
+ condition]
|> String.concat ","
list.Add line
diff --git a/src/Paket.Core/PublicAPI.fs b/src/Paket.Core/PublicAPI.fs
index 8740ad2285..57dffc63b3 100644
--- a/src/Paket.Core/PublicAPI.fs
+++ b/src/Paket.Core/PublicAPI.fs
@@ -600,6 +600,13 @@ type Dependencies(dependenciesFileName: string) =
|> Seq.map (fun kv -> kv.Key.ToString())
|> Seq.toList
+ member __.GetConditions(): string list =
+ let dependenciesFile = DependenciesFile.ReadFromFile dependenciesFileName
+ dependenciesFile.Groups
+ |> Seq.choose (fun kv -> kv.Value.Options.Settings.ReferenceCondition)
+ |> Seq.distinct
+ |> Seq.toList
+
/// Returns the direct dependencies for the given package.
member this.GetDirectDependenciesForPackage(groupName,packageName:string): (string * string * string) list =
let resolvedPackages = this.GetLockFile().GetGroupedResolution()
@@ -855,6 +862,9 @@ type Dependencies(dependenciesFileName: string) =
doc.Save fileStream
static member FixNuspecs (projectFile: ProjectFile, referencesFile:ReferencesFile, nuspecFileList:string list) =
+ Dependencies.FixNuspecs (projectFile, referencesFile, nuspecFileList, [])
+
+ static member FixNuspecs (projectFile: ProjectFile, referencesFile:ReferencesFile, nuspecFileList:string list, conditions:string list) =
let attr (name: string) (node: XmlNode) =
match node.Attributes.[name] with
| null -> None
@@ -880,8 +890,14 @@ type Dependencies(dependenciesFileName: string) =
|> List.map (fun proj -> proj.NameWithoutExtension)
|> Set.ofList
let depsFile = deps.GetDependenciesFile()
+ let groupMatchesConditions groupName =
+ let group = depsFile.GetGroup(groupName)
+ match group.Options.Settings.ReferenceCondition with
+ | None -> true
+ | Some condition -> conditions |> List.contains condition
let allFrameworkRestrictions =
locked.GetPackageHull referencesFile
+ |> Seq.filter (fun kvp -> fst kvp.Key |> groupMatchesConditions)
|> Seq.map(fun kvp -> snd kvp.Key, fst kvp.Key, kvp.Value.Settings.FrameworkRestrictions.GetExplicitRestriction())
@@ -898,6 +914,7 @@ type Dependencies(dependenciesFileName: string) =
let projectReferencedDeps =
referencesFile.Groups
+ |> Seq.filter (fun (KeyValue(group, _)) -> group |> groupMatchesConditions)
|> Seq.collect (fun (KeyValue(group, packages)) -> packages.NugetPackages |> Seq.map (fun p -> group, p))
let groupsForProjectReferencedDeps =
diff --git a/src/Paket.Core/embedded/Paket.Restore.targets b/src/Paket.Core/embedded/Paket.Restore.targets
index bbeec153f5..0749ac7968 100644
--- a/src/Paket.Core/embedded/Paket.Restore.targets
+++ b/src/Paket.Core/embedded/Paket.Restore.targets
@@ -240,8 +240,9 @@
$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[6])
$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[7])
$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[8])
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[9])
-
+
%(PaketReferencesFileLinesInfo.PackageVersion)
All
runtime
@@ -250,7 +251,6 @@
%(PaketReferencesFileLinesInfo.Aliases)
true
true
-
@@ -314,7 +314,17 @@
-
+
+
+
+
+ <_DefinedConditionProperties Include="@(_ConditionProperties)" Condition="$(%(Identity)) == 'true'"/>
+
+
+ <_ConditionsParameter>
+ <_ConditionsParameter Condition="@(_DefinedConditionProperties) != ''">--conditions @(_DefinedConditionProperties)
+
+
diff --git a/src/Paket/Commands.fs b/src/Paket/Commands.fs
index 1794bf3222..6910575295 100644
--- a/src/Paket/Commands.fs
+++ b/src/Paket/Commands.fs
@@ -412,6 +412,7 @@ type FixNuspecsArgs =
| [] Files of nuspecPaths:string list
| [] ReferencesFile of referencePath:string
| [] ProjectFile of referencePath:string
+ | [] Conditions of conditions:string list
with
interface IArgParserTemplate with
member this.Usage =
@@ -419,6 +420,7 @@ with
| Files _ -> ".nuspec files to fix transitive dependencies within"
| ReferencesFile _ -> "paket.references to use"
| ProjectFile _ -> "the project file to use"
+ | Conditions _ -> "group conditions to filter by"
type GenerateNuspecArgs =
| [] Project of project:string
@@ -451,6 +453,12 @@ with
interface IArgParserTemplate with
member __.Usage = ""
+type ShowConditionsArgs =
+ | [] NoArgs
+with
+ interface IArgParserTemplate with
+ member __.Usage = ""
+
type FindPackageVersionsArgs =
| [] NuGet of package_ID:string
| [] NuGet_Legacy of package_ID:string
@@ -696,6 +704,7 @@ type Command =
| [] GenerateNuspec of ParseResults
| [] ShowInstalledPackages of ParseResults
| [] ShowGroups of ParseResults
+ | [] ShowConditions of ParseResults
| [] Pack of ParseResults
| [] Push of ParseResults
| [] GenerateIncludeScripts of ParseResults
@@ -729,6 +738,7 @@ with
| GenerateNuspec _ -> "generate a default nuspec for a project including its direct dependencies"
| ShowInstalledPackages _ -> "show installed top-level packages"
| ShowGroups _ -> "show groups"
+ | ShowConditions _ -> "show conditions defined on groups"
| Pack _ -> "create NuGet packages from paket.template files"
| Push _ -> "push a NuGet package"
| GenerateIncludeScripts _ -> "[obsolete]"
diff --git a/src/Paket/Program.fs b/src/Paket/Program.fs
index 1d5f8f8b2f..ffbba31f47 100644
--- a/src/Paket/Program.fs
+++ b/src/Paket/Program.fs
@@ -577,7 +577,7 @@ let pack (results : ParseResults<_>) =
|> legacyBool results (ReplaceArgument("--symbols", "symbols"))
let includeReferencedProjects =
(results.Contains PackArgs.Include_Referenced_Projects,
- results.Contains PackArgs.Include_Referenced_Projects_Legacy)
+ results.Contains PackArgs.Include_Referenced_Projects_Legacy)
|> legacyBool results (ReplaceArgument("--include-referenced-projects", "Include_Referenced_Projects"))
let projectUrl =
(results.TryGetResult PackArgs.Project_Url,
@@ -680,12 +680,17 @@ let fixNuspecs silent (results : ParseResults<_>) =
results.GetResult FixNuspecsArgs.Files
|> List.collect (fun s -> s.Split([|';'|], StringSplitOptions.RemoveEmptyEntries) |> Array.toList)
|> List.map (fun s -> s.Trim())
+ let conditions =
+ results.TryGetResult FixNuspecsArgs.Conditions
+ |> Option.defaultValue []
+ |> List.collect (fun s -> s.Split([|';'|], StringSplitOptions.RemoveEmptyEntries) |> Array.toList)
+ |> List.map (fun s -> s.Trim())
match results.TryGetResult FixNuspecsArgs.ProjectFile with
| Some projectFile ->
let projectFile = Paket.ProjectFile.LoadFromFile(projectFile)
let refFile = RestoreProcess.FindOrCreateReferencesFile projectFile
- Dependencies.FixNuspecs (projectFile, refFile, nuspecFiles)
+ Dependencies.FixNuspecs (projectFile, refFile, nuspecFiles, conditions)
| None ->
match results.TryGetResult FixNuspecsArgs.ReferencesFile with
| Some referenceFile ->
@@ -736,6 +741,11 @@ let showGroups (results : ParseResults) =
for groupName in dependenciesFile.GetGroups() do
tracefn "%s" groupName
+let showConditions (results : ParseResults) =
+ let dependenciesFile = Dependencies.Locate()
+ for condition in dependenciesFile.GetConditions() do
+ tracefn "%s" condition
+
let findPackageVersions (results : ParseResults<_>) =
let maxResults =
let arg = (results.TryGetResult FindPackageVersionsArgs.Max_Results,
@@ -894,6 +904,7 @@ let handleCommand silent command =
| FixNuspecs r -> processCommand silent (fixNuspecs silent) r
| ShowInstalledPackages r -> processCommand silent showInstalledPackages r
| ShowGroups r -> processCommand silent showGroups r
+ | ShowConditions r -> processCommand silent showConditions r
| Pack r -> processCommand silent pack r
| Push r -> processCommand silent (push paketVersion) r
| GenerateIncludeScripts r ->
diff --git a/tests/Paket.Tests/InstallModel/PaketPropsTests.fs b/tests/Paket.Tests/InstallModel/PaketPropsTests.fs
index 03675ba766..2550579e4a 100644
--- a/tests/Paket.Tests/InstallModel/PaketPropsTests.fs
+++ b/tests/Paket.Tests/InstallModel/PaketPropsTests.fs
@@ -19,8 +19,8 @@ let checkTargetFrameworkCondition msbuildCondition (itemGroup: XElement) =
let checkTargetFrameworkNoRestriction itemGroup =
checkTargetFrameworkCondition "" itemGroup
-let checkTargetFrameworkRestriction r itemGroup =
- let msbuildCond = r |> Paket.Requirements.getExplicitRestriction |> fun c -> c.ToMSBuildCondition()
+let checkTargetFrameworkRestriction rc r itemGroup =
+ let msbuildCond = r |> Paket.Requirements.getExplicitRestriction |> fun c -> PlatformMatching.getCondition rc c.RepresentedFrameworks
checkTargetFrameworkCondition (sprintf " AND (%s)" msbuildCond) itemGroup
let checkContainsPackageRefs pkgRefs (group: XElement) =
@@ -186,11 +186,127 @@ group Other1
match itemGroups with
| [groupMain; otherGroup] ->
groupMain
- |> checkTargetFrameworkRestriction lockFile.Groups.[Constants.MainDependencyGroup].Options.Settings.FrameworkRestrictions
+ |> checkTargetFrameworkRestriction lockFile.Groups.[Constants.MainDependencyGroup].Options.Settings.ReferenceCondition lockFile.Groups.[Constants.MainDependencyGroup].Options.Settings.FrameworkRestrictions
groupMain
|> checkContainsPackageRefs [ "FSharp.Core","3.1.2.5"; "Argu","4.2.1" ]
otherGroup
- |> checkTargetFrameworkRestriction lockFile.Groups.[Domain.GroupName "Other1"].Options.Settings.FrameworkRestrictions
+ |> checkTargetFrameworkRestriction lockFile.Groups.[Domain.GroupName "Other1"].Options.Settings.ReferenceCondition lockFile.Groups.[Domain.GroupName "Other1"].Options.Settings.FrameworkRestrictions
+ otherGroup
+ |> checkContainsPackageRefs [ "FSharp.Core","4.3.4"; "FsCheck","2.8.2" ]
+ | l ->
+ Assert.Fail(sprintf "expected two ItemGroup but was '%A'" l)
+
+[]
+let ``should create props file for design mode with group conditions``() =
+
+ let lockFile = """CONDITION: COND_MAIN
+NUGET
+ remote: https://api.nuget.org/v3/index.json
+ Argu (4.2.1)
+ FSharp.Core (>= 3.1.2)
+ FSharp.Core (3.1.2.5)
+
+GROUP Other1
+CONDITION: COND_OTHER1
+NUGET
+ remote: https://api.nuget.org/v3/index.json
+ FsCheck (2.8.2)
+ FSharp.Core (>= 3.1.2.5)
+ FSharp.Core (4.3.4)
+"""
+
+ let refFileContent = """
+FSharp.Core
+Argu
+
+group Other1
+ FSharp.Core
+ FsCheck
+"""
+
+ let lockFile = LockFile.Parse("", toLines lockFile)
+
+ let refFile = ReferencesFile.FromLines(toLines refFileContent)
+
+ let packages =
+ [ for kv in refFile.Groups do
+ let packagesInGroup,_ = lockFile.GetOrderedPackageHull(kv.Key, refFile)
+ yield! packagesInGroup ]
+
+ let outPath = System.IO.Path.GetTempFileName()
+ Paket.RestoreProcess.createPaketPropsFile lockFile Seq.empty packages (FileInfo outPath)
+
+ let doc = XDocument.Load(outPath, LoadOptions.PreserveWhitespace)
+
+ let itemGroups = doc.Root.Elements (xname "ItemGroup") |> Seq.toList
+
+ match itemGroups with
+ | [groupMain; otherGroup] ->
+ groupMain
+ |> checkTargetFrameworkRestriction lockFile.Groups.[Constants.MainDependencyGroup].Options.Settings.ReferenceCondition lockFile.Groups.[Constants.MainDependencyGroup].Options.Settings.FrameworkRestrictions
+ groupMain
+ |> checkContainsPackageRefs [ "FSharp.Core","3.1.2.5"; "Argu","4.2.1" ]
+ otherGroup
+ |> checkTargetFrameworkRestriction lockFile.Groups.[Domain.GroupName "Other1"].Options.Settings.ReferenceCondition lockFile.Groups.[Domain.GroupName "Other1"].Options.Settings.FrameworkRestrictions
+ otherGroup
+ |> checkContainsPackageRefs [ "FSharp.Core","4.3.4"; "FsCheck","2.8.2" ]
+ | l ->
+ Assert.Fail(sprintf "expected two ItemGroup but was '%A'" l)
+
+[]
+let ``should create props file for design mode with group restrictions and conditions``() =
+
+ let lockFile = """CONDITION: COND_MAIN
+RESTRICTION: && (>= net461) (< net47)
+NUGET
+ remote: https://api.nuget.org/v3/index.json
+ Argu (4.2.1)
+ FSharp.Core (>= 3.1.2)
+ FSharp.Core (3.1.2.5)
+
+GROUP Other1
+CONDITION: COND_OTHER1
+RESTRICTION: == netstandard2.0
+NUGET
+ remote: https://api.nuget.org/v3/index.json
+ FsCheck (2.8.2)
+ FSharp.Core (>= 3.1.2.5)
+ FSharp.Core (4.3.4)
+"""
+
+ let refFileContent = """
+FSharp.Core
+Argu
+
+group Other1
+ FSharp.Core
+ FsCheck
+"""
+
+ let lockFile = LockFile.Parse("", toLines lockFile)
+
+ let refFile = ReferencesFile.FromLines(toLines refFileContent)
+
+ let packages =
+ [ for kv in refFile.Groups do
+ let packagesInGroup,_ = lockFile.GetOrderedPackageHull(kv.Key, refFile)
+ yield! packagesInGroup ]
+
+ let outPath = System.IO.Path.GetTempFileName()
+ Paket.RestoreProcess.createPaketPropsFile lockFile Seq.empty packages (FileInfo outPath)
+
+ let doc = XDocument.Load(outPath, LoadOptions.PreserveWhitespace)
+
+ let itemGroups = doc.Root.Elements (xname "ItemGroup") |> Seq.toList
+
+ match itemGroups with
+ | [groupMain; otherGroup] ->
+ groupMain
+ |> checkTargetFrameworkRestriction lockFile.Groups.[Constants.MainDependencyGroup].Options.Settings.ReferenceCondition lockFile.Groups.[Constants.MainDependencyGroup].Options.Settings.FrameworkRestrictions
+ groupMain
+ |> checkContainsPackageRefs [ "FSharp.Core","3.1.2.5"; "Argu","4.2.1" ]
+ otherGroup
+ |> checkTargetFrameworkRestriction lockFile.Groups.[Domain.GroupName "Other1"].Options.Settings.ReferenceCondition lockFile.Groups.[Domain.GroupName "Other1"].Options.Settings.FrameworkRestrictions
otherGroup
|> checkContainsPackageRefs [ "FSharp.Core","4.3.4"; "FsCheck","2.8.2" ]
| l ->
@@ -243,17 +359,17 @@ group Other2
match itemGroups with
| [groupMain; otherGroup20And21; otherGroupOnly21] ->
groupMain
- |> checkTargetFrameworkRestriction lockFile.Groups.[Constants.MainDependencyGroup].Options.Settings.FrameworkRestrictions
+ |> checkTargetFrameworkRestriction lockFile.Groups.[Constants.MainDependencyGroup].Options.Settings.ReferenceCondition lockFile.Groups.[Constants.MainDependencyGroup].Options.Settings.FrameworkRestrictions
groupMain
|> checkContainsPackageRefs [ "FSharp.Core","3.1.2.5"; "Argu","4.2.1" ]
otherGroup20And21
- |> checkTargetFrameworkRestriction lockFile.Groups.[Domain.GroupName "Other2"].Options.Settings.FrameworkRestrictions
+ |> checkTargetFrameworkRestriction lockFile.Groups.[Domain.GroupName "Other2"].Options.Settings.ReferenceCondition lockFile.Groups.[Domain.GroupName "Other2"].Options.Settings.FrameworkRestrictions
otherGroup20And21
|> checkContainsPackageRefs [ "FSharp.Core","4.3.4" ]
otherGroupOnly21
- |> checkTargetFrameworkRestriction lockFile.Groups.[Domain.GroupName "Other2"].Resolution.[Domain.PackageName "FsCheck"].Settings.FrameworkRestrictions
+ |> checkTargetFrameworkRestriction lockFile.Groups.[Domain.GroupName "Other2"].Options.Settings.ReferenceCondition lockFile.Groups.[Domain.GroupName "Other2"].Resolution.[Domain.PackageName "FsCheck"].Settings.FrameworkRestrictions
otherGroupOnly21
|> checkContainsPackageRefs [ "FsCheck","2.8.2" ]
| l ->
@@ -286,11 +402,11 @@ Newtonsoft.Json
let doc = XDocument.Load(outPath, LoadOptions.PreserveWhitespace)
let itemGroups = doc.Root.Elements (xname "ItemGroup") |> Seq.toList
-
+
match itemGroups with
| [groupMain] ->
groupMain
- |> checkTargetFrameworkRestriction lockFile.Groups.[Constants.MainDependencyGroup].Resolution.[Domain.PackageName "Newtonsoft.Json"].Settings.FrameworkRestrictions
+ |> checkTargetFrameworkRestriction lockFile.Groups.[Constants.MainDependencyGroup].Options.Settings.ReferenceCondition lockFile.Groups.[Constants.MainDependencyGroup].Resolution.[Domain.PackageName "Newtonsoft.Json"].Settings.FrameworkRestrictions
groupMain
|> checkContainsPackageRefs [ "Newtonsoft.Json","11.0.2" ]
| l ->