Skip to content

Commit cc8ccab

Browse files
Expand test matrix for conditional TargetFramework(s) fix (#3799)
- Add MicrosoftNetSdkWithConditionalTargetFrameworksOnly.csprojtest fixture that reproduces the exact original issue shape (no unconditional TargetFramework/TargetFrameworks fallback element). - Add case-insensitive configuration coverage (dEbUg/rElEaSe) for the conditional-frameworks fixture. - Add a test asserting the correct default framework (first listed) is picked per configuration. - Add a test asserting GetOutputDirectory resolves the output path for a specific requested TargetProfile (net45) inside conditional PropertyGroups. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent acd9efd commit cc8ccab

3 files changed

Lines changed: 45 additions & 1 deletion

File tree

tests/Paket.Tests/Paket.Tests.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
<Compile Include="Simplifier\BasicScenarioSpecs.fs" />
132132
<TestAsset Include="ProjectFile\TestData\MicrosoftNetSdkWithTargetFrameworkAndOutputPath.csprojtest" />
133133
<TestAsset Include="ProjectFile\TestData\MicrosoftNetSdkWithConditionalTargetFrameworks.csprojtest" />
134+
<TestAsset Include="ProjectFile\TestData\MicrosoftNetSdkWithConditionalTargetFrameworksOnly.csprojtest" />
134135
<TestAsset Include="ProjectFile\TestData\EmptyFsharpGuid.fsprojtest" />
135136
<TestAsset Include="ProjectFile\TestData\EmptyVbGuid.vbprojtest" />
136137
<TestAsset Include="ProjectFile\TestData\EmptyPyGuid.pyprojtest" />

tests/Paket.Tests/ProjectFile/OutputSpecs.fs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,46 @@ let ``should detect output path for netsdk with outputPath and appendTargetFrame
105105

106106
[<Test>]
107107
let ``should detect output path for netsdk with conditional target frameworks csproj file``
108-
([<Values("Debug", "Release")>] configuration) =
108+
([<Values("Debug", "Release", "dEbUg", "rElEaSe")>] configuration) =
109109
ensureDir ()
110110
let projectFile = ProjectFile.TryLoad("./ProjectFile/TestData/MicrosoftNetSdkWithConditionalTargetFrameworks.csprojtest").Value
111111
// Should not throw "Unable to find <configuration> output path node" (see issue #3799)
112112
let outPath = projectFile.GetOutputDirectory configuration "" None
113113
outPath |> shouldNotEqual ""
114114

115+
[<Test>]
116+
let ``should detect output path for netsdk with only conditional target frameworks (no unconditional fallback) csproj file``
117+
([<Values("Debug", "Release")>] configuration) =
118+
ensureDir ()
119+
// Reproduces the exact shape from issue #3799: no unconditional TargetFramework/TargetFrameworks
120+
// element exists at all, only Configuration-conditioned PropertyGroups.
121+
let projectFile = ProjectFile.TryLoad("./ProjectFile/TestData/MicrosoftNetSdkWithConditionalTargetFrameworksOnly.csprojtest").Value
122+
let outPath = projectFile.GetOutputDirectory configuration "" None
123+
outPath |> shouldNotEqual ""
124+
125+
[<Test>]
126+
let ``should pick the conditional target frameworks matching the requested configuration for netsdk csproj file``
127+
([<Values("Debug", "Release")>] configuration) =
128+
ensureDir ()
129+
let projectFile = ProjectFile.TryLoad("./ProjectFile/TestData/MicrosoftNetSdkWithConditionalTargetFrameworksOnly.csprojtest").Value
130+
let outPath = projectFile.GetOutputDirectory configuration "" None
131+
// Debug config only lists netstandard2.0;net45, Release additionally lists net47;
132+
// the first framework in each list is netstandard2.0, and it should be selected as the default.
133+
let expected = (System.IO.Path.Combine(@"bin", configuration, "netstandard2.0") |> normalizePath)
134+
outPath.ToLowerInvariant() |> shouldEqual (expected.ToLowerInvariant())
135+
136+
[<Test>]
137+
let ``should detect output path for a specific target profile in a conditional target frameworks csproj file``
138+
([<Values("Debug", "Release")>] configuration) =
139+
ensureDir ()
140+
let projectFile = ProjectFile.TryLoad("./ProjectFile/TestData/MicrosoftNetSdkWithConditionalTargetFrameworksOnly.csprojtest").Value
141+
let targetProfile =
142+
FrameworkDetection.internalExtract "net45"
143+
|> Option.map TargetProfile.SinglePlatform
144+
let outPath = projectFile.GetOutputDirectory configuration "" targetProfile
145+
let expected = (System.IO.Path.Combine(@"bin", configuration, "net45") |> normalizePath)
146+
outPath.ToLowerInvariant() |> shouldEqual (expected.ToLowerInvariant())
147+
115148
[<Test>]
116149
let ``should detect framework profile for ProjectWithConditions file`` () =
117150
ensureDir ()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
4+
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
5+
</PropertyGroup>
6+
7+
<PropertyGroup Condition="'$(Configuration)'=='Release'">
8+
<TargetFrameworks>netstandard2.0;net45;net47</TargetFrameworks>
9+
</PropertyGroup>
10+
</Project>

0 commit comments

Comments
 (0)