Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paket pack should work with BuildOutputTargetFolder and AppendTargetFrameworkToOutputPath. #3165

Merged
merged 6 commits into from Apr 25, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions integrationtests/Paket.IntegrationTests/PackSpecs.fs
Expand Up @@ -309,7 +309,6 @@ let ``#1538 symbols src folder structure`` () =

CleanDir rootPath


[<Test>]
[<Ignore("ignore until we hear back")>]
let ``#1504 unpacking should override``() =
Expand Down Expand Up @@ -552,4 +551,17 @@ let ``#2788 with include-pdbs true`` () =
Path.Combine(outPath, "lib", "net45", "BuiltWithSymbols.xml") |> checkFileExists
Path.Combine(outPath, "lib", "net45", "BuiltWithSymbols.pdb") |> checkFileExists

CleanDir rootPath
CleanDir rootPath

[<Test>]
let ``#3164 pack analyzer`` () =
let scenario = "i003164-pack-analyzer"
let rootPath = scenarioTempPath scenario
let outPath = Path.Combine(rootPath, "out")
paket ("pack \"" + outPath + "\"") scenario |> ignore

let package = Path.Combine(outPath, "Analyzer.0.2.0.3-dev.nupkg")
ZipFile.ExtractToDirectory(package, outPath)
Path.Combine(outPath, "analyzers", "dotnet", "cs", "Analyzer.dll") |> checkFileExists

CleanDir rootPath
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2037
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Analyzer", "Analyzer\Analyzer.csproj", "{175FF0F8-19E4-45EB-BCAB-F975B5D21BD0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{175FF0F8-19E4-45EB-BCAB-F975B5D21BD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{175FF0F8-19E4-45EB-BCAB-F975B5D21BD0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{175FF0F8-19E4-45EB-BCAB-F975B5D21BD0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{175FF0F8-19E4-45EB-BCAB-F975B5D21BD0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AD7A2832-E55B-4538-97B9-F4DBB6805A17}
EndGlobalSection
EndGlobal
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.3</TargetFramework>
<BuildOutputTargetFolder>analyzers\dotnet\cs</BuildOutputTargetFolder>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>

<PropertyGroup>
<Description>Roslyn analyzers for Gu.Localization.</Description>
<Authors>Johan Larsson</Authors>
<Version>0.2.0.3-dev</Version>
<NeutralLanguage>en</NeutralLanguage>
<PackageLicenseUrl>http://opensource.org/licenses/MIT</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/GuOrg/Gu.Localization</PackageProjectUrl>
<RepositoryUrl>https://github.com/GuOrg/Gu.Localization</RepositoryUrl>
<PackageTags>roslyn analyzer</PackageTags>
<PackageReleaseNotes>Initial</PackageReleaseNotes>
</PropertyGroup>
</Project>
@@ -0,0 +1,6 @@
namespace Analyzer
{
public class Class1
{
}
}
Binary file not shown.
@@ -0,0 +1,2 @@
type project

@@ -0,0 +1,18 @@
source https://www.nuget.org/api/v2

group Roslyn
storage: none
source http://nuget.org/api/v2
nuget Microsoft.CodeAnalysis.CSharp.Workspaces 2.3.1
nuget System.Collections.Immutable 1.3.1
nuget System.Reflection.Metadata 1.4.2
nuget Microsoft.Composition 1.0.31

group Analyzers
storage: none
source http://www.nuget.org/api/v2/
nuget AsyncUsageAnalyzers
nuget Gu.Analyzers
nuget IDisposableAnalyzers
nuget StyleCop.Analyzers

707 changes: 707 additions & 0 deletions integrationtests/scenarios/i003164-pack-analyzer/before/paket.lock

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions src/Paket.Core/Packaging/PackageMetaData.fs
Expand Up @@ -163,9 +163,12 @@ let addFile (source : string) (target : string) (templateFile : TemplateFile) =
let findDependencies (dependenciesFile : DependenciesFile) config platform (template : TemplateFile) (project : ProjectFile) lockDependencies minimumFromLockFile pinProjectReferences (projectWithTemplates : Map<string, (Lazy<'TemplateFile>) * ProjectFile * bool>) includeReferencedProjects (version :SemVerInfo option) projDeps =
let includeReferencedProjects = template.IncludeReferencedProjects || includeReferencedProjects
let targetDir =
match project.OutputType with
| ProjectOutputType.Exe -> "tools/"
| ProjectOutputType.Library -> project.GetTargetProfiles() |> List.map (sprintf "lib/%O/") |> List.head // TODO: multi target pack
match project.BuildOutputTargetFolder with
| Some x -> x
| None ->
match project.OutputType with
| ProjectOutputType.Exe -> "tools/"
| ProjectOutputType.Library -> project.GetTargetProfiles() |> List.map (sprintf "lib/%O/") |> List.head // TODO: multi target pack

let projectDir = Path.GetDirectoryName project.FileName

Expand Down
19 changes: 18 additions & 1 deletion src/Paket.Core/PaketConfigFiles/ProjectFile.fs
Expand Up @@ -1524,6 +1524,17 @@ module ProjectFile =
|> Seq.tryHead
|> function None -> ProjectOutputType.Library | Some x -> x

let buildOutputTargetFolder (project:ProjectFile) =
project.Document
|> getDescendants "BuildOutputTargetFolder"
|> Seq.tryHead
|> Option.map (fun e -> e.InnerText)

let appendTargetFrameworkToOutputPath (project:ProjectFile) =
match project.Document |> getDescendants "AppendTargetFrameworkToOutputPath" |> Seq.tryHead with
| Some e -> not (String.Equals(e.InnerText, "false", StringComparison.OrdinalIgnoreCase))
| None -> true

let addImportForPaketTargets relativeTargetsPath (project:ProjectFile) =
match project.Document
|> getDescendants "Import"
Expand Down Expand Up @@ -1608,7 +1619,9 @@ module ProjectFile =
let rec tryNextPlat platforms attempted =
match platforms with
| [] ->
if not (String.IsNullOrEmpty targetFramework) then
if not (appendTargetFrameworkToOutputPath project) then
Path.Combine("bin", buildConfiguration)
elif not (String.IsNullOrEmpty targetFramework) then
Path.Combine("bin", buildConfiguration, targetFramework)
elif String.IsNullOrWhiteSpace buildPlatform then
failwithf "Unable to find %s output path node in file %s for any known platforms" buildConfiguration project.FileName
Expand Down Expand Up @@ -1738,6 +1751,10 @@ type ProjectFile with

member this.OutputType = ProjectFile.outputType this

member this.BuildOutputTargetFolder = ProjectFile.buildOutputTargetFolder this

member this.AppendTargetFrameworkToOutputPath = ProjectFile.appendTargetFrameworkToOutputPath this

member this.GetTargetFrameworkIdentifier () = ProjectFile.getTargetFrameworkIdentifier this

member this.GetTargetFrameworkProfile () = ProjectFile.getTargetFrameworkProfile this
Expand Down
5 changes: 4 additions & 1 deletion tests/Paket.Tests/Paket.Tests.fsproj
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\FSharp.Compiler.Tools\build\FSharp.Compiler.Tools.props" Condition="Exists('..\..\packages\FSharp.Compiler.Tools\build\FSharp.Compiler.Tools.props')" Label="Paket" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
Expand Down Expand Up @@ -232,6 +232,9 @@
<Compile Include="ReferencesFile\ReferencesFileSpecs.fs" />
<Compile Include="LocalFile\LocalFileSpecs.fs" />
<Compile Include="Simplifier\BasicScenarioSpecs.fs" />
<None Include="ProjectFile\TestData\AnalyzerProject.csprojtest">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ProjectFile\TestData\MicrosoftNetSdkWithTargetFrameworkAndOutputPath.csprojtest">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
24 changes: 24 additions & 0 deletions tests/Paket.Tests/ProjectFile/OutputSpecs.fs
Expand Up @@ -26,6 +26,30 @@ let ``should detect exe output type for Project3 proj file``() =
ProjectFile.TryLoad("./ProjectFile/TestData/Project3.fsprojtest").Value.OutputType
|> shouldEqual ProjectOutputType.Exe

[<Test>]
let ``should detect BuildOutputTargetFolder none for Project3 proj file``() =
ensureDir ()
ProjectFile.TryLoad("./ProjectFile/TestData/Project3.fsprojtest").Value.BuildOutputTargetFolder
|> shouldEqual None

[<Test>]
let ``should detect BuildOutputTargetFolder for AnalyzerProject proj file``() =
ensureDir ()
ProjectFile.TryLoad("./ProjectFile/TestData/AnalyzerProject.csprojtest").Value.BuildOutputTargetFolder
|> shouldEqual (Some "analyzers\dotnet\cs")

[<Test>]
let ``should detect AppendTargetFrameworkToOutputPath for MicrosoftNetSdkWithTargetFrameworkAndOutputPath proj file``() =
ensureDir ()
ProjectFile.TryLoad("./ProjectFile/TestData/MicrosoftNetSdkWithTargetFrameworkAndOutputPath.csprojtest").Value.AppendTargetFrameworkToOutputPath
|> shouldEqual true

[<Test>]
let ``should detect AppendTargetFrameworkToOutputPath for AnalyzerProject proj file``() =
ensureDir ()
ProjectFile.TryLoad("./ProjectFile/TestData/AnalyzerProject.csprojtest").Value.AppendTargetFrameworkToOutputPath
|> shouldEqual false

[<Test>]
let ``should detect target framework for Project1 proj file``() =
ensureDir ()
Expand Down
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.3</TargetFramework>
<BuildOutputTargetFolder>analyzers\dotnet\cs</BuildOutputTargetFolder>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
</Project>