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

pyproj support #2885

Merged
merged 2 commits into from
Nov 7, 2017
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
*.pyproj merge=union

# Standard to msysgit
*.doc diff=astextplain
Expand Down
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1836,7 +1836,7 @@
* Package names in Dependencies file are no longer case-sensitive - https://github.com/fsprojects/Paket/pull/108

#### 0.1.4 - 2014-09-16
* Only vbproj, csproj and fsproj files are handled
* Only vbproj, csproj, fsproj and pyproj files are handled

#### 0.1.3 - 2014-09-15
* Detect FSharpx.Core in packages
Expand Down
3 changes: 2 additions & 1 deletion docs/content/analyzers.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ conforms to the
for analyzers to be installed by NuGet in `project.json`-based projects.

If the `<language></language>` is absent from the path the analyzer will be
installed in any supported project type (`.csproj`, `.vbproj` and `.fsproj`).
installed in any supported project type (`.csproj`, `.vbproj`, `.fsproj` and `.pyproj`).
If it is present the analyzer will only be installed in the corresponding
project type:

* `cs` -> `.csproj`
* `vb` -> `.vbproj`
* `fs` -> `.fsproj`
* `py` -> `.pyproj`

**Remarks:**

Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/Installation/BindingRedirects.fs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ let internal indentAssemblyBindings config =
parent.Remove()

let private configFiles = [ "app"; "web" ] |> Set.ofList
let private projectFiles = [ ".csproj"; ".vbproj"; ".fsproj"; ".wixproj"; ".nproj"; ".vcxproj" ] |> Set.ofList
let private projectFiles = [ ".csproj"; ".vbproj"; ".fsproj"; ".wixproj"; ".nproj"; ".vcxproj"; ".pyproj" ] |> Set.ofList
let private toLower (s:string) = s.ToLower()
let private isAppOrWebConfig = configFiles.Contains << (Path.GetFileNameWithoutExtension >> toLower)
let private isDotNetProject = projectFiles.Contains << (Path.GetExtension >> toLower)
Expand Down
24 changes: 16 additions & 8 deletions src/Paket.Core/PaketConfigFiles/ProjectFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type ProjectOutputType =
| Exe
| Library

type ProjectLanguage = Unknown | CSharp | FSharp | VisualBasic | WiX | Nemerle | CPP
type ProjectLanguage = Unknown | CSharp | FSharp | VisualBasic | WiX | Nemerle | CPP | IronPython

module LanguageEvaluation =
let private extractProjectTypeGuids (projectDocument:XmlDocument) =
Expand Down Expand Up @@ -104,18 +104,25 @@ module LanguageEvaluation =
[
"{EDCC3B85-0BAD-11DB-BC1A-00112FDE8B61}" // Nemerle
] |> List.map Guid.Parse |> Set.ofList

let private ironPythonGuids =
[
"{D499C55F-46C0-4FE1-8D05-02605C1891EA}" // IronPython
] |> List.map Guid.Parse |> Set.ofList

let private getGuidLanguage (guid:Guid) =
let isCsharp = csharpGuids.Contains(guid)
let isVb = vbGuids.Contains(guid)
let isFsharp = fsharpGuids.Contains(guid)
let isNemerle = nemerleGuids.Contains(guid)

match (isCsharp, isVb, isFsharp, isNemerle) with
| (true, false, false, false) -> Some CSharp
| (false, true, false, false) -> Some VisualBasic
| (false, false, true, false) -> Some FSharp
| (false, false, false, true) -> Some Nemerle
let isIronPython = ironPythonGuids.Contains(guid)

match (isCsharp, isVb, isFsharp, isNemerle, isIronPython) with
| (true, false, false, false, false) -> Some CSharp
| (false, true, false, false, false) -> Some VisualBasic
| (false, false, true, false, false) -> Some FSharp
| (false, false, false, true, false) -> Some Nemerle
| (false, false, false, false, true) -> Some IronPython
| _ -> None

let private getLanguageFromExtension = function
Expand All @@ -125,6 +132,7 @@ module LanguageEvaluation =
| ".vcxproj" -> Some CPP
| ".wixproj" -> Some WiX
| ".nproj" -> Some Nemerle
| ".pyproj" -> Some IronPython
| _ -> None

let private getLanguageFromFileName (fileName : string) =
Expand Down Expand Up @@ -163,7 +171,7 @@ type ProjectFile =

[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module ProjectFile =
let supportedEndings = [ ".csproj"; ".fsproj"; ".vbproj"; ".wixproj"; ".nproj"; ".vcxproj"]
let supportedEndings = [ ".csproj"; ".fsproj"; ".vbproj"; ".wixproj"; ".nproj"; ".vcxproj"; ".pyproj"]

let isSupportedFile (fi:FileInfo) =
supportedEndings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ let ``should generate Xml for RefactoringEssentials in VisualBasic project``() =
ctx.AnalyzersNode
|> (fun n -> n.OuterXml)
|> normalizeXml
|> shouldEqual (normalizeXml expected)
|> shouldEqual (normalizeXml expected)
3 changes: 3 additions & 0 deletions tests/Paket.Tests/Paket.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@
<None Include="ProjectFile\TestData\EmptyVbGuid.vbprojtest">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ProjectFile\TestData\EmptyPyGuid.pyprojtest">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ProjectFile\TestData\Project1.fsprojtest">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
4 changes: 4 additions & 0 deletions tests/Paket.Tests/ProjectFile/FileBuildActionSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,28 @@ let ``should recognize compilable files``() =
(createProject "B.fsproj").DetermineBuildAction "Module.fsi" |> shouldEqual BuildAction.Compile
(createProject "C.vbproj").DetermineBuildAction "Whatever.vb" |> shouldEqual BuildAction.Compile
(createProject "D.nproj").DetermineBuildAction "Main.n" |> shouldEqual BuildAction.Compile
(createProject "E.pyproj").DetermineBuildAction "Class.py" |> shouldEqual BuildAction.Compile

[<Test>]
let ``should recognize content files``() =
(createProject "A.csproj").DetermineBuildAction "Something.js" |> shouldEqual BuildAction.Content
(createProject "B.fsproj").DetermineBuildAction "config.yml" |> shouldEqual BuildAction.Content
(createProject "C.vbproj").DetermineBuildAction "noext" |> shouldEqual BuildAction.Content
(createProject "D.nproj").DetermineBuildAction "App.config" |> shouldEqual BuildAction.Content
(createProject "E.pyproj").DetermineBuildAction "Something.xml" |> shouldEqual BuildAction.Content

[<Test>]
let ``should recognize page files``() =
(createProject "A.csproj").DetermineBuildAction "Form1.xaml" |> shouldEqual BuildAction.Page
(createProject "B.fsproj").DetermineBuildAction "Form1.Xaml" |> shouldEqual BuildAction.Page
(createProject "C.vbproj").DetermineBuildAction "Form1.XAML" |> shouldEqual BuildAction.Page
(createProject "D.nproj" ).DetermineBuildAction "Form1.XaML" |> shouldEqual BuildAction.Page
(createProject "E.pyproj" ).DetermineBuildAction "Form1.xaml" |> shouldEqual BuildAction.Page

[<Test>]
let ``should recognize resource files``() =
(createProject "A.csproj").DetermineBuildAction "Form1.ttf" |> shouldEqual BuildAction.Resource
(createProject "B.fsproj").DetermineBuildAction "Form1.ico" |> shouldEqual BuildAction.Resource
(createProject "C.vbproj").DetermineBuildAction "Form1.png" |> shouldEqual BuildAction.Resource
(createProject "D.nproj" ).DetermineBuildAction "Form1.jpg" |> shouldEqual BuildAction.Resource
(createProject "E.pyproj" ).DetermineBuildAction "Form1.jpg" |> shouldEqual BuildAction.Resource
7 changes: 7 additions & 0 deletions tests/Paket.Tests/ProjectFile/TestData/EmptyPyGuid.pyprojtest
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<ProjectTypeGuid>D499C55F-46C0-4FE1-8D05-02605C1891EA</ProjectTypeGuid>
</PropertyGroup>
</Project>