1
-4
2
6
3
5
4
5
.NET 11 Preview 7 is now available! (devblogs.microsoft.com)
5
3
6
0
7
4
8
3
9
5
.NET 11 Preview 6 is now available! (devblogs.microsoft.com)
10
1
11
5

When using Central Package Management (Directory.Packages.props holds package versions), package version declarations can remain after package references have been removed. The package versions are unused and misleading.

dotnet nuget why can be used to get a dependency tree across projects to answer how a package comes into the dependency tree. However, the extensive tree list result for a list of version declarations is not viable to simply determine what 'is in use' and what isn't.

I am sharing my Nushell snippet which answers the question of what is declared but not referenced:

# List Directory.Packages.props version declarations that are in no csproj
def "dotnet unused-dirpackprops" [] {
  let defs = open Directory.Packages.props | from xml | get content | where tag == ItemGroup | get content.attributes.Include | flatten | sort --ignore-case --natural
  let refs = ls **/*.csproj | get name | each { open | from xml | get content | select content | flatten | flatten | where tag == PackageReference | get attributes.Include } | flatten | uniq | sort --ignore-case --natural
  $defs | difference $refs
}
❯ dotnet unused-dirpackprops
╭───┬─────────────────────────────────────────╮
│ 0 │ coverlet.collector                      │
│ 1 │ System.Net.Http                         │
│ 2 │ System.ServiceProcess.ServiceController │
╰───┴─────────────────────────────────────────╯

Gaps: In this simple form, only covers the standard csproj package references. Package references included during build through other target or prop files are not covered (probably irrelevant for most users).

12
5
13
3
14
9
15
1
16
3
.NET 11 Preview 5 is now available! (devblogs.microsoft.com)
submitted 2 months ago by nemeski@mander.xyz to c/dotnet@programming.dev
17
3
submitted 2 months ago by nemeski@mander.xyz to c/dotnet@programming.dev
18
9
submitted 2 months ago by nemeski@mander.xyz to c/dotnet@programming.dev
19
7
20
2
Deprecating dotMemory Unit (blog.jetbrains.com)
submitted 2 months ago by nemeski@mander.xyz to c/dotnet@programming.dev
21
6
submitted 2 months ago by nemeski@mander.xyz to c/dotnet@programming.dev
22
7
23
11
Process API Improvements in .NET 11 (devblogs.microsoft.com)
submitted 3 months ago by nemeski@mander.xyz to c/dotnet@programming.dev
24
8
submitted 3 months ago by nemeski@mander.xyz to c/dotnet@programming.dev
25
2

I wrote a blog post about me getting in to FSharp web application development, but am having issues deciding how I want the data access to look. I'm very much open to feedback!

view more: next ›

.NET

1865 readers
6 users here now

Getting started

Useful resources

IDEs and code editors

Tools

Rules

Related communities

Wikipedia pages

founded 3 years ago
MODERATORS