Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions src/Paket.Core/PaketConfigFiles/ProjectFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -993,19 +993,26 @@ module ProjectFile =
let getTargetFrameworkIdentifier (project:ProjectFile) = getProperty "TargetFrameworkIdentifier" project

let getTargetFrameworkProfile (project:ProjectFile) = getProperty "TargetFrameworkProfile" project
let getTargetFrameworkVersion (project:ProjectFile) = getProperty "TargetFrameworkVersion" project
let getTargetFramework (project:ProjectFile) = getProperty "TargetFramework" project
let getTargetFrameworks (project:ProjectFile) = getProperty "TargetFrameworks" project


let getTargetProfile (project:ProjectFile) =
let fallback () =
let prefix =
match getTargetFrameworkIdentifier project with
| None -> "net"
| Some x -> x
let framework = getProperty "TargetFrameworkVersion" project
let framework =
match getTargetFrameworkVersion project with
| None -> getTargetFramework project
| Some x -> Some(prefix + x.Replace("v",""))
let defaultResult = SinglePlatform (DotNetFramework FrameworkVersion.V4)
match framework with
| None -> defaultResult
| Some s ->
match FrameworkDetection.Extract(prefix + s.Replace("v","")) with
match FrameworkDetection.Extract(s) with
| None -> defaultResult
| Some x -> SinglePlatform x

Expand Down Expand Up @@ -1432,6 +1439,11 @@ module ProjectFile =
sprintf "%s.%s" assemblyName ending

let getOutputDirectory buildConfiguration buildPlatform (project:ProjectFile) =
let targetFramework =
match getTargetFramework project with
| Some x -> x
| None -> ""

let platforms =
if not <| String.IsNullOrWhiteSpace buildPlatform then
[buildPlatform]
Expand All @@ -1449,12 +1461,14 @@ module ProjectFile =
let rec tryNextPlat platforms attempted =
match platforms with
| [] ->
if String.IsNullOrWhiteSpace(buildPlatform) then
if String.IsNullOrEmpty(targetFramework) = false then
Path.Combine("bin", buildConfiguration, targetFramework)
else if String.IsNullOrWhiteSpace(buildPlatform) then
failwithf "Unable to find %s output path node in file %s for any known platforms" buildConfiguration project.FileName
else
failwithf "Unable to find %s output path node in file %s targeting the %s platform" buildConfiguration project.FileName buildPlatform
| x::xs ->
let startingData = Map.ofList [("Configuration", buildConfiguration); ("Platform", x)]
let startingData = Map.ofList [("Configuration", buildConfiguration); ("TargetFramework", targetFramework);("Platform", x)]
[getPropertyWithDefaults "OutputPath" startingData project; getPropertyWithDefaults "OutDir" startingData project]
|> List.choose id
|> function
Expand All @@ -1463,7 +1477,7 @@ module ProjectFile =
if String.IsNullOrWhiteSpace buildPlatform && attempted <> [] then
let tested = String.Join(", ", attempted)
traceWarnfn "No platform specified; found output path node for the %s platform after failing to find one for the following: %s" x tested
s.TrimEnd [|'\\'|] |> normalizePath
Path.Combine(s.TrimEnd [|'\\'|] , targetFramework) |> normalizePath

tryNextPlat platforms []

Expand Down
10 changes: 8 additions & 2 deletions tests/Paket.Tests/Paket.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@
<Compile Include="ReferencesFile\ReferencesFileSpecs.fs" />
<Compile Include="LocalFile\LocalFileSpecs.fs" />
<Compile Include="Simplifier\BasicScenarioSpecs.fs" />
<None Include="ProjectFile\TestData\EmptyCsharpGuid.csprojtest">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<None Include="ProjectFile\TestData\MicrosoftNetSdkWithTargetFrameworkAndOutputPath.csprojtest">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ProjectFile\TestData\EmptyFsharpGuid.fsprojtest">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down Expand Up @@ -275,6 +275,12 @@
<None Include="ProjectFile\TestData\Unity.csprojtest">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ProjectFile\TestData\EmptyCsharpGuid.csprojtest">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ProjectFile\TestData\MicrosoftNetSdkWithTargetFramework.csprojtest">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Compile Include="ProjectFile\ConditionSpecs.fs" />
<Compile Include="ProjectFile\TargetFrameworkSpecs.fs" />
<Compile Include="ProjectFile\FileBuildActionSpecs.fs" />
Expand Down
23 changes: 23 additions & 0 deletions tests/Paket.Tests/ProjectFile/OutputSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,29 @@ let ``should detect output path for proj file``
let expected = (System.IO.Path.Combine(@"bin", configuration) |> normalizePath)
outPath.ToLowerInvariant() |> shouldEqual (expected.ToLowerInvariant())

[<Test>]
let ``should detect output path for netsdk csproj file``
([<Values("MicrosoftNetSdkWithTargetFramework.csprojtest")>] project)
([<Values("Debug", "Release", "dEbUg", "rElEaSe")>] configuration) =
ensureDir ()
let projectFile = ProjectFile.TryLoad(sprintf "./ProjectFile/TestData/%s" project).Value
let>
let outPath = projectFile.GetOutputDirectory configuration ""
let expected = (System.IO.Path.Combine(@"bin", configuration, target) |> normalizePath)
outPath.ToLowerInvariant() |> shouldEqual (expected.ToLowerInvariant())

[<Test>]
let ``should detect output path for netsdk with outputPath csproj file``
([<Values("MicrosoftNetSdkWithTargetFrameworkAndOutputPath.csprojtest")>] project)
([<Values("Release")>] configuration) =
ensureDir ()
let projectFile = ProjectFile.TryLoad(sprintf "./ProjectFile/TestData/%s" project).Value
let>
let outPath = projectFile.GetOutputDirectory configuration ""
let expected = (System.IO.Path.Combine(@"bin", configuration,"netstandard1.4_bin", target) |> normalizePath)
outPath.ToLowerInvariant() |> shouldEqual (expected.ToLowerInvariant())


[<Test>]
let ``should detect framework profile for ProjectWithConditions file`` () =
ensureDir ()
Expand Down
4 changes: 4 additions & 0 deletions tests/Paket.Tests/ProjectFile/TargetFrameworkSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ let TestData: obj[][] =
portable;
"portable-net45+win8+wp8+wpa81";
(DotNetFramework FrameworkVersion.V4_5)|];
[|"MicrosoftNetSdkWithTargetFramework.csprojtest";
(SinglePlatform(DotNetStandard DotNetStandardVersion.V1_4));
"netstandard1.4";
(DotNetStandard DotNetStandardVersion.V1_4)|];
|]

[<Test>]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AssemblyName>TestPaket</AssemblyName>
<TargetFramework>netstandard1.4</TargetFramework>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AssemblyName>TestPaket</AssemblyName>
<TargetFramework>netstandard1.4</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<OutputPath>bin\Release\netstandard1.4_bin\</OutputPath>
</PropertyGroup>
</Project>