This is a .net tool that analyze your solution folder, discover all your project files and diagnose all the nuget packages if they require attention, such as any project contains outdated packages or inconsistent package versions, etc. And it can be used as validation process by your CI/CD pipelines.
Pre-request
- .Net Core 3.1
NuSight is analyzing solution and discovering all project nuget packages.
-
list command: analyze nuget packages if contains:
- outdated packages within the same solution
- inconsistent package versions within the same solution
- pre-released packages within the same solution
- unpublished packages within the same solution
-
export command: export all package references from the selected solution folder into a json file
-
import command: import all pakcages and install them from selected json file.
-
update command: update all outdated packages for selected solution.
-
delete command: delete all targeted packages for selected solution and all its projects.
-
clone command: copy all nuget packages references and install them to targeted project.
- Using
dotnet tool install -g NuSight
to install the console tool from nuget
$ dotnet tool install -g NuSight
a command can be used for your CI build to validate your nuget packages for the whole solution.
- --help or -h to list all parameters and descriptions
$ nusight list -h
- --solution or -s to specify the selected solution path, if you haven't specified any solution path, it will take current directory as selected path
$ nusight list -s=<YOUR_PATH>
- --inconsistency or -i to triage inconsistent nuget package versions installed in the selected solution
$ nusight list -s=<YOUR_PATH> -i
- --outdated or -o to triage outdated nuget packages installed in the selected solution
$ nusight list -s=<YOUR_PATH> -o
- --prereleased or -p to triage if any pre-released packages are installed in the selected solution
$ nusight list -s=<YOUR_PATH> -p
- --unpublished or -u to triage if any unpublished packages are installed in the selected solution.
$ nusight list -s=<YOUR_PATH> -u
If the triage finds any above errors, it will return with an error code, and your pipeline will fail. Otherwise return with a 0 code and pipeline will succeed.
a command can be used for bulk updating packages in multiple projects under a solution folder.
- --help or -h to list all parameters and descriptions
$ nusight update -h
- --solution or -s to specify the selected solution path, if you haven't specified any solution path, it will take current directory as selected path
$ nusight update -s=<YOUR_PATH>
- --display or -d allows you only print 'dotnet update' commands on the screen, instead of executing it. If you don't specify this, update commands will be run and update packages in the selected solution.
$ nusight update -s=<YOUR_PATH> -d
a command can be used for bulk removing packages in multiple projects under a solution folder.
- --help or -h to list all parameters and descriptions
$ nusight remove -h
- --solution or -s to specify the selected solution path, if you haven't specified any solution path, it will take current directory as selected path
$ nusight remove -s=<YOUR_PATH>
- --package or -p to specify the package name to be removed, if you want to select multiple packages, use comma separated values
$ nusight remove -s=<YOUR_PATH> -p=Serilog
- --display or -d allows you only print 'dotnet remove' commands on the screen, instead of executing it. If you don't specify this, remove commands will be run and remove packages in the selected solution.
$ nusight remove -s=<YOUR_PATH> -p=Serilog -d
a command can be used for cloning all nuget packages from a source solution/project to a target project, this is handy if you have a template project and its nuget packages will always be used for any future projects, you can always clone your them to the new projects.
- --help or -h to list all parameters and descriptions
$ nusight clone -h
- --source or -s to specify the source solution path
$ nusight clone -s=<YOUR_PATH>
- --target or -t to specify the target project path, it must be a csproj
$ nusight clone -s=<YOUR_PATH> -t=<TARGET_PATH>/<PROJECT>.csproj
- --display or -d allows you only print 'dotnet install' commands on the screen, instead of executing it. If you don't specify this, install commands will be run and install packages in the target project.
$ nusight clone -s=<YOUR_PATH> -t=<TARGET_PATH>/<PROJECT>.csproj -d
- --latest or -l to specify if you want to copy nuget packages from source solution with latest version.
$ nusight clone -s=<YOUR_PATH> -t=<TARGET_PATH>/<PROJECT>.csproj -l
a command can be used for exporting nuget package reference as json file.
- --help or -h to list all parameters and descriptions
$ nusight export -h
- --source or -s to specify the source solution path
$ nusight export -s=<YOUR_PATH>
- --file or -f to specify the exported file path and name
$ nusight export -s=<YOUR_PATH> -f=<FILE_PATH>/<FILE_NAME>.json
a command can be used for importing nuget packages from an exported json file.
- --help or -h to list all parameters and descriptions
$ nusight import -h
- --solution or -s to specify the selected solution path to be imported to.
$ nusight import -s=<YOUR_PATH>
- --file or -f to specify the exported file path and name
$ nusight import -s=<YOUR_PATH> -f=<FILE_PATH>/<FILE_NAME>.json
- --display or -d allows you only print 'dotnet install' commands on the screen, instead of executing it. If you don't specify this, install commands will be run and install packages in the target project.
$ nusight import -s=<YOUR_PATH> -f=<FILE_PATH>/<FILE_NAME>.json -d
- name: Nuget triage
working-directory: ./MyProject
run: |
dotnet tool install -g NuSight
nusight list -o -p -u -i
build:
stage: 'build'
script:
- dotnet restore
- dotnet build
- dotnet tool install -g NuSight
- nusight list -o -p -u -i
when: always
Reach out to me at one of the following places!
TODO