Skip to content

Commit cf5af6f

Browse files
committed
[ANE-2523] NuGet: analyze every .csproj in a directory
PackageReference discovery used `find isPackageRefFile` which returned only the first match. Sibling project files in the same directory were silently dropped. Switch to `filter` so each .csproj/.xproj/.vbproj/ .dbproj/.fsproj yields its own NuGetProject.
1 parent f44528b commit cf5af6f

6 files changed

Lines changed: 39 additions & 4 deletions

File tree

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Config: `paths.only` and `paths.exclude` in `.fossa.yml` now accept glob patterns. ([#1703](https://github.com/fossas/fossa-cli/pull/1703))
66
- Licensing - Fix two bad GPL matches [No PR]
7+
- NuGet: PackageReference discovery now analyzes every `.csproj`/`.xproj`/`.vbproj`/`.dbproj`/`.fsproj` in a directory. Previously only the first match returned by the directory listing was analyzed, so sibling project files were silently dropped.
78

89

910
## 3.17.5

spectrometer.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ test-suite unit-tests
692692
Node.PackageLockSpec
693693
Node.PackageLockV3Spec
694694
NuGet.DirectoryPackagesPropsSpec
695+
NuGet.NuGetSpec
695696
NuGet.NuspecSpec
696697
NuGet.PackageReferenceSpec
697698
NuGet.PackagesConfigSpec

src/Strategy/NuGet.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import Control.Effect.Reader (Reader)
1616
import Data.Aeson (
1717
ToJSON,
1818
)
19-
import Data.Foldable (find)
2019
import Data.List qualified as L
2120
import Discovery.Filters (AllFilters)
2221
import Discovery.Simple (simpleDiscover)
@@ -51,9 +50,7 @@ findProjects :: (Has ReadFS sig m, Has Diagnostics sig m, Has (Reader AllFilters
5150
findProjects = walkWithFilters' $ \_ _ files -> do
5251
case findProjectAssetsJsonFile files of
5352
Just file -> pure ([NuGetProject file], WalkContinue)
54-
Nothing -> case find isPackageRefFile files of
55-
Just file -> pure ([NuGetProject file], WalkContinue)
56-
Nothing -> pure ([], WalkContinue)
53+
Nothing -> pure (map NuGetProject (filter isPackageRefFile files), WalkContinue)
5754
where
5855
findProjectAssetsJsonFile :: [Path Abs File] -> Maybe (Path Abs File)
5956
findProjectAssetsJsonFile = findFileNamed "project.assets.json"

test/NuGet/NuGetSpec.hs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{-# LANGUAGE TemplateHaskell #-}
2+
3+
module NuGet.NuGetSpec (
4+
spec,
5+
) where
6+
7+
import Path (mkRelDir, mkRelFile, (</>))
8+
import Path.IO (getCurrentDir)
9+
import Strategy.NuGet (NuGetProject (..))
10+
import Strategy.NuGet qualified as NuGet
11+
import Test.Effect (it', shouldMatchList')
12+
import Test.Hspec (Spec, describe, runIO)
13+
import Types (DiscoveredProject (projectData))
14+
15+
spec :: Spec
16+
spec = do
17+
currDir <- runIO getCurrentDir
18+
let projectDir = currDir </> $(mkRelDir "test/NuGet/testdata/multi-csproj")
19+
appCore = projectDir </> $(mkRelFile "App.Core.csproj")
20+
ingageWeb = projectDir </> $(mkRelFile "IngageWeb.csproj")
21+
describe "NuGet discovery" $
22+
it' "discovers every .csproj sibling in a directory (ANE-2523)" $ do
23+
projects <- NuGet.discover projectDir
24+
let files = map (nugetProjectFile . projectData) projects
25+
files `shouldMatchList'` [appCore, ingageWeb]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
3+
<ItemGroup>
4+
<PackageReference Include="AutoMapper" Version="12.0.1" />
5+
</ItemGroup>
6+
</Project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
3+
<ItemGroup>
4+
</ItemGroup>
5+
</Project>

0 commit comments

Comments
 (0)