slnutil 2.19.0

dotnet tool install --global slnutil --version 2.19.0                
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local slnutil --version 2.19.0                
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=slnutil&version=2.19.0                
nuke :add-package slnutil --version 2.19.0                

slnutil

A collection of utilities for working with .NET Core Solutions and Projects.

Written by Benjamin Day
Pluralsight Author | Microsoft MVP | Scrum.org Professional Scrum Trainer
https://www.benday.com
https://www.slidespeaker.ai
info@benday.com
YouTube: https://www.youtube.com/@_benday

Key features

  • Create solutions and projects with unit tests & integration tests for...
  • Create class diagrams for all or part of a project using Mermaid
  • Update the .NET Framework version for all projects in a solution
  • Set or increment the assembly version for a project
  • Set a project property value in a csproj file
  • Deploy Entity Framework Core Migrations from a DLL (aka. deploy migrations without the source code)
  • Validate a connection string against SQL Server to make sure it connects
  • Bulk rename files and folders
  • Edit json from the command line
  • Set the connection string in appsettings.json form the command line
  • And lots more...

Suggestions, Problems, or Bugs?

Got ideas for utilities you'd like to see? Found a bug? Let us know by submitting an issue https://github.com/benday-inc/slnutil/issues. Want to contribute? Submit a pull request.

Installing

The slnutil is distributed as a .NET Core Tool via NuGet. To install it go to the command prompt and type
dotnet tool install slnutil -g

Prerequisites

Commands

Command Name Description
assemblyinfo View assembly info for a DLL.
rename Bulk rename for files and folders.
classdiagram Generate a class diagram for an assembly.
cleanreferences Simplifies package references in a C# project file. Mostly this fixes stuff in the EF Core references that breaks Azure DevOps & GitHub builds like PrivateAssets and IncludeAssets directives.
createsolution Create a solution and projects
deployefmigrations Deploy EF Core Migrations from DLL binaries.
devtreeclean Clean development folder tree. Removes node_modules, .git, bin, obj, and TestResults folders.
findsolutions Find solution files in a folder tree.
formatxml Formats XML files
getconnectionstring Get database connection string in appsettings.json.
classesfromjson Create C# classes from JSON with serialization attributes for System.Text.Json.
listpackages-oldstyle Lists packages referenced in legacy style packages.config files.
listsolutionprojects Gets list of projects in a solution.
replacetoken Replace token in file.
setconnectionstring Set database connection string in appsettings.json.
setframework Set the target framework version on all projects.
setjsonvalue Set a string value in a json file.
setprojectproperty Set a project property value on all projects.
setprojectversion Set the assembly and nuget package version property value on a project.
base64 Encodes a string value as a base 64 string.
touch Modifies a file's date to current date time or creates a new empty file if it doesn't exist.
validateconnectionstring Validate that specified connection string can connect to SQL Server.
wildcardreference Changes package references in a C# project file to use wildcard version rather than fixed version number.

assemblyinfo

View assembly info for a DLL.

Arguments

Argument Is Optional Data Type Description
filename Required String Assembly to view

rename

Bulk rename for files and folders.

Arguments

Argument Is Optional Data Type Description
rootdir Optional String Starting directory for the rename operation
from Required String String to search for and replace
to Required String Replacement value
preview Optional Boolean Preview changes
recursive Optional Boolean Recurse the directory tree

classdiagram

Generate a class diagram for an assembly.

Arguments

Argument Is Optional Data Type Description
namespace Optional String Filter by namespace
filename Required String Path to assembly that you want a class diagram for.
hideinheritance Optional Boolean Hide inheritance relationships.
typenamesmatchexact Optional Boolean Exact match for type names. Default is contains.
localonly Optional Boolean Only show methods and properties that are declared locally. Don't show inherited members.
typenames Optional String Show types that exist in this comma separated list. Default search is contains match that matches by substring.

cleanreferences

Simplifies package references in a C# project file. Mostly this fixes stuff in the EF Core references that breaks Azure DevOps & GitHub builds like PrivateAssets and IncludeAssets directives.

Arguments

Argument Is Optional Data Type Description
solutionpath Optional String Solution file to use
preview Optional Boolean Preview changes only

createsolution

Create a solution and projects

Arguments

Argument Is Optional Data Type Description
rootdir Optional String Starting directory. If not supplied, the tool uses the current directory.
type Required String Type of solution to create. Valid values are: webapi, mvc, console, commands, maui, maui-demo
namespace Required String This is the root namespace for the solution. For example: Benday.SampleApp

deployefmigrations

Deploy EF Core Migrations from DLL binaries.

Arguments

Argument Is Optional Data Type Description
binariesdir Optional String Path to EF Core migration binaries. Defaults to current directory.
startupdll Optional String Path to EF Core startup DLL.
migrationsdll Optional String Path to EF Core migrations DLL.
dbcontextname Optional String Name of the EF Core DbContext class.
namespace Optional String Root namespace of the EF Core migrations DLL.
verbose Optional Boolean Output results as comma-separated values

devtreeclean

Clean development folder tree. Removes node_modules, .git, bin, obj, and TestResults folders.

Arguments

Argument Is Optional Data Type Description
rootdir Optional String Starting directory. If not supplied, the tool uses the current directory.
keepgit Optional Boolean If true, skips delete of .git folders and preserves any git repositories. Default value is true. Set this value to false to delete .git folders.

findsolutions

Find solution files in a folder tree.

Arguments

Argument Is Optional Data Type Description
rootdir Required String Path to start search from
listprojects Optional Boolean List projects in solutions
csv Optional Boolean Output results as comma-separated values
skipreferences Optional Boolean Output results as comma-separated values

formatxml

Formats XML files

Arguments

Argument Is Optional Data Type Description
filename Optional String Path to file or wildcard to files
recursive Optional Boolean Apply to matching files recursively
write Optional Boolean Write changes back to the file

getconnectionstring

Get database connection string in appsettings.json.

Arguments

Argument Is Optional Data Type Description
filename Optional String Path to json config file
name Required String Name of the connection string to get

classesfromjson

Create C# classes from JSON with serialization attributes for System.Text.Json.

Arguments

Argument Is Optional Data Type Description

listpackages-oldstyle

Lists packages referenced in legacy style packages.config files.

Arguments

Argument Is Optional Data Type Description
rootdir Optional String Path to start search from

listsolutionprojects

Gets list of projects in a solution.

Arguments

Argument Is Optional Data Type Description
solutionpath Optional String Solution to examine. If this value is not supplied, the tool searches for a sln file automatically.
pathonly Optional Boolean Only show the project paths. Don't show the framework versions.

replacetoken

Replace token in file.

Arguments

Argument Is Optional Data Type Description
filename Required String Path to file
token Required String Token to replace
value Required String String value to set

setconnectionstring

Set database connection string in appsettings.json.

Arguments

Argument Is Optional Data Type Description
filename Optional String Path to json config file
name Required String Name of the connection string to set
value Required String Connection string value

setframework

Set the target framework version on all projects.

Arguments

Argument Is Optional Data Type Description
solutionpath Optional String Solution to examine. If this value is not supplied, the tool searches for a sln file automatically.
version Required String Framework version to set projects to.

setjsonvalue

Set a string value in a json file.

Arguments

Argument Is Optional Data Type Description
filename Optional String Path to json config file
level1 Required String First level json property name to set
level2 Optional String Second level json property name to set
level3 Optional String Third level json property name to set
level4 Optional String Fourth level json property name to set
value Required String String value to set
increment-int Optional Boolean Increment the existing value or use the '/value' as the value if it does not exist or isn't an integer.
increment-minor-version Optional Boolean Increment the minor version of the existing value or use the '/value' as the value if it does not exist or isn't an integer.
bool Optional Boolean Set value into the json as boolean

setprojectproperty

Set a project property value on all projects.

Arguments

Argument Is Optional Data Type Description
solutionpath Optional String Solution to examine. If this value is not supplied, the tool searches for a sln file automatically.
propertyname Required String Name of the property to set.
propertyvalue Required String Value for the property.

setprojectversion

Set the assembly and nuget package version property value on a project.

Arguments

Argument Is Optional Data Type Description
solutionpath Optional String Solution to examine. If this value is not supplied, the tool searches for a sln file automatically.
project Required String Project name to update.
increment Optional Boolean Increment the minor value.
value Optional String Value for the property.

base64

Encodes a string value as a base 64 string.

Arguments

Argument Is Optional Data Type Description
value Required String Value to encode as base64

touch

Modifies a file's date to current date time or creates a new empty file if it doesn't exist.

Arguments

Argument Is Optional Data Type Description
filename Required String Path to file

validateconnectionstring

Validate that specified connection string can connect to SQL Server.

Arguments

Argument Is Optional Data Type Description
filename Optional String Path to json config file
name Required String Name of the connection string to validate

wildcardreference

Changes package references in a C# project file to use wildcard version rather than fixed version number.

Arguments

Argument Is Optional Data Type Description
solutionpath Optional String Solution file to use
preview Optional Boolean Preview changes only
filter Optional String Filter package by name. If package name starts with this value, it gets updated.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
2.19.0 73 1/20/2025
2.17.0 229 11/27/2024
2.16.0 239 11/13/2024
2.15.0 152 10/31/2024
2.14.0 131 10/27/2024
2.13.0 177 10/4/2024
2.12.0 91 10/3/2024
2.11.0 216 9/10/2024
2.10.0 391 5/20/2024
2.9.0 100 5/20/2024
2.8.0 185 5/6/2024
2.7.0 118 4/24/2024
2.6.0 251 3/26/2024
2.5.0 156 2/6/2024
2.4.0 179 2/5/2024
2.3.0 145 2/5/2024
2.2.0 231 12/18/2023
2.1.0 162 12/18/2023
2.0.0 190 12/15/2023
1.10.0 235 10/4/2023
1.9.0 215 10/2/2023
1.8.0 177 8/24/2023
1.7.0 272 5/18/2023
1.6.0 220 4/21/2023
1.5.1 232 4/4/2023
1.5.0 225 4/4/2023
1.4.1 232 3/17/2023
1.4.0 228 3/7/2023
1.3.0 248 3/5/2023
1.1.1 248 3/3/2023
1.1.0 238 3/3/2023
1.0.0 238 3/3/2023

v2.19 - Bug fixes; Support in class diagram for protected members; Class diagram option for showing locally defined members
 v2.18 - Fixing bugs in formatxml command
 v2.17 - Fixing bugs in class diagram generator
 v2.16 - Restored the devtreeclean command which had been accidentally removed.
 v2.15 - You don't wanna know. It was a mess.
 v2.14 - Generate class diagrams for an assembly.
 v2.13 - Added xml formatter command that allows recursive file processing.
 v2.12 - Command to update or increment package version number and assembly version number.
 v2.11 - Added support for setting values as json boolean in via setjsonvalue.
 v2.10 - Fixed bug in setprojectproperty command where values were not updated if the property already existed.
 v2.9 - Added assembly info viewer.
 v2.8 - Added option to devtreeclean to keep git repositories when cleaning a directory tree.
 v2.7 - Added wildcard reference command.
 v2.6 - Updated nuget package to include Benday.CommandsFramework v3.2.0.
 v2.5 - Updated jsontoclasses to add support for hyphens in json property names.