synthphonic / nsmgr-cli Goto Github PK
View Code? Open in Web Editor NEWnautilus-cli or nautilus solution manager (nsmgr) is an open source cli tool to help developers to maintain their solution and projects in it.
nautilus-cli or nautilus solution manager (nsmgr) is an open source cli tool to help developers to maintain their solution and projects in it.
The following are the necessary logics needed to ensure of a successful nuget package update for a particular project.
1. Create a new CLI command
nuget-package-update --solutionfilename=xxx --project=xxx.xxx
--nugetpackage=MySample.XamarinForms
--nugetversion=3.6.22.11122
2. Validation: Ensure the .sln path and the file exists
This is a crucial step to ensure that the .sln file exists. We can use File.IsExists() to see if the path is correct.
3. Validation: Ensure the targeted project exist
If from (2) is true, then extract the solution file. Use linq to filter the project listing in the solution instance to get the exact project name. if linq query returns a single result, then we are good for step (4)
4. Validation: Ensure nuget package exists in the targeted project
By this time, the project should return a list of nuget packages it uses. Query the nuget package and see if the result is true or false. If true, the go to step (5)
5. Validation: Version number validation
Once we have the package name, the version number will be associated with it as well. Regardless of the current version that the project use, here we need to query the latest version from nuget package website to ensure the targeted version is available. If not, we throw exception here.
6. Update nuget package:
If in (5) is true, and the target version exists, we need to update either the packages.config or the .csproj file accordingly. The criterias are as below:
Check if packages.config file exists, if does then update the nuget package version there.
If NETStandard or NETCore prject, then update the .csproj
If Native iOS and Android project, update .csproj file (PackageReference section)
If Native library/Native Binding Library projects, update the packages.config file
In short, when the command line is run successfully, a successful result will be of the following:
Summary
Good to have option to ensure that findconflict has the ability to turn on automatic nuget package update.
It can also be turned off in which it will mean that the findconflict command is meant to report to eh user only via the CLI interface
Proposal
dotnet nautilus-cli findconflict --solutionfilename=xxxx --autoupdate={true|false}
where --autoupdate switch is default to false
NOTE
This feature will need to be implemented after #1 and #2 are completed
Proposal
List and show all projects that falls under a particular solution
The list should be in the following format
Storiveo.WebApi [CSharp] [NETStandard20]
where...
{ProjectName} {[ProjectType]} {TargetFramework}
The default total number of commands allowed using parser.ParseArguments<T1,T2...,T16>(...)
was 16.
Using the array approach, we can cater more than that in a single cli tool
API Documentation
Query for all packages published to nuget.org
Samples
https://api-v2v3search-0.nuget.org/query?q=Xamarin.Forms&prerelease=false
https://api-v2v3search-0.nuget.org/query
https://api.nuget.org/v3/index.json
Testing
Include testing
To design a basic CLI container for nautilus-cli
To design "services"
use the --debug option to write the output to a log file. Currently, --debug option only outputs the exception on the console in red color.
the log file should be saved in the user's root physical file path.
to fix errors
Creating a command with nested sub commands can be too verbose. If we could modify the way we generate commands via fluent api would be a great experience for future new commands
For Document reference, refer to https://github.com/synthphonic/nautilus-cli/issues/29
command:
nsmgr package find -s ~/projects/project.sln -n Xamarin.Forms --show-error
... where project.sln is the fullpath that targets older .net framework version
CSharpNETFrameworkProjectFileReader class does not implement CSharpNETFrameworkProjectFileReader.ReadVersion(fileName) method
`[ERR] The method or operation is not implemented.
at Nautilus.SolutionExplorer.Core.FileReaders.CSharpNETFrameworkProjectFileReader.ReadVersion(String fileName) in /Users/shahz.macbook/projects/synthphonic/nautilus-cli/src/Nautilus.SolutionExplorer.Core/FileReaders/CSharpNETFrameworkProjectFileReader.cs:line 49
at Nautilus.SolutionExplorer.Core.FileReaderContext.ReadVersion() in /Users/shahz.macbook/projects/synthphonic/nautilus-cli/src/Nautilus.SolutionExplorer.Core/FileReaderContext.cs:line 144
at Nautilus.SolutionExplorer.Core.Models.Project.ReadbyProjectMetadata() in /Users/shahz.macbook/projects/synthphonic/nautilus-cli/src/Nautilus.SolutionExplorer.Core/Models/Project.cs:line 104
at Nautilus.SolutionExplorer.Core.Models.Project.Read() in /Users/shahz.macbook/projects/synthphonic/nautilus-cli/src/Nautilus.SolutionExplorer.Core/Models/Project.cs:line 67
at Nautilus.SolutionExplorer.Core.FileReaders.SolutionFileReader.Read() in /Users/shahz.macbook/projects/synthphonic/nautilus-cli/src/Nautilus.SolutionExplorer.Core/FileReaders/SolutionFileReader.cs:line 39
at Nautilus.Cli.Client.Commands.FindPackageCommand.RunAsync() in /Users/shahz.macbook/projects/synthphonic/nautilus-cli/src/Nautilus.Cli.Client/Commands/FindPackageCommand.cs:line 22
at Nautilus.Cli.Client.Commands.FindPackageCommand.ExecuteAsync() in /Users/shahz.macbook/projects/synthphonic/nautilus-cli/src/Nautilus.Cli.Client/Commands/FindPackageCommand.cs:line 16
at CommandGeneratorExtensions.<>c.<b__22_0>d.MoveNext() in /Users/shahz.macbook/projects/synthphonic/nautilus-cli/src/Nautilus.Cli.Client/AppStartup/CommandGeneratorExtensions.cs:line 294`
Nuget Package reference:
CommandLineParser
Documentation & Usage
commandlineparser/commandline
Consolidation
tab and the Updates
tabnuget cli
also has this feature.dotnet cli
also has this feature (if im not mistaken)nsmgr
to update a package version in csprojdotnet restore
at the solution level once the package is updated in the csproj filecopy nsmgr to /usr/local/bin
folder and test it out
dotnet-ef requires x64 SDK on macOS Monterey with Apple Silicon (M1) #25927
dotnet-ef requires x64 SDK on macOS Monterey with Apple Silicon (M1) #25927
Refer to PACKAGING.md
This issue is related to #13
The following verb causes exceptions thrown
verb: list-projects
options used:
-- solutionfilename
-- projects-only
-- nuget-packages=true
-- debug=true
-- nuget-package-updates
sample command line used:
dotnet nautilus-cli.dll list-projects --solutionfilename=/pathtosample_project/_aaaaaaaa.sln --projects-only --nuget-packages=true --debug=true --nuget-package-updates
Exception thrown:
2019-09-16 13:16:14.654 +08:00 [ERR] Object reference not set to an instance of an object.
at Nautilus.Cli.Core.Models.NugetPackageInformationComparer.get_IsLatestVersion() in /Users/shahz.macbook/projects/fiftyonelab/nautilus-cli/src/Nautilus.Cli.Core/Models/NugetPackageInformationComparer.cs:line 20
at Nautilus.Cli.Client.CommandLine.Services.ListProjectsService.DisplayNugetPackages(Project project, Dictionary2 packageVersionComparer) in /Users/shahz.macbook/projects/fiftyonelab/nautilus-cli/src/nautilus-cli/CommandLine/Services/ListProjectsService.cs:line 129 at Nautilus.Cli.Client.CommandLine.Services.ListProjectsService.WriteToScreen(Solution solution, Dictionary
2 packageVersionComparer) in /Users/shahz.macbook/projects/fiftyonelab/nautilus-cli/src/nautilus-cli/CommandLine/Services/ListProjectsService.cs:line 93
at Nautilus.Cli.Client.CommandLine.Services.ListProjectsService.Run() in /Users/shahz.macbook/projects/fiftyonelab/nautilus-cli/src/nautilus-cli/CommandLine/Services/ListProjectsService.cs:line 64
Feature is already in list-projects -s ~/projects/xxx.sln -p
.
However it is intended for nuget packages work. We can create a new command using list-projects
and refactor the code to get the intended out only.
list-targetframeworks -s ~/projects/xxx.sln
Documentation
Sample to publish for MacOS X
dotnet publish -c Release --framework netcoreapp2.2 --runtime osx-x64 --self-contained true
Work on:
Nuget Package reference:
Colorful.Console
Documentation & Usage
Colorful.Console
Logging of exceptions should be done into a text file.
Some useful links for R&D
Name: szs
Date: 24 May 2022
Repository Handle (if exists): github.com/synthphonic
Version of a particular csproj file should be easy to change. The "Version" xml element usually resides in the first "PropertyGroup" element in a particular csproj file.
nsmgr cli tool should be able to cater for this modification with ease
Not available
Long Name | Short Name | Description |
---|---|---|
--project-path |
-p |
Required: true. The full file path of a given csproj file name. |
--version-number |
-n |
Required: true. The new version number. |
--backup |
-b |
Default: false. Prior to version change, the command should backup the original version number. |
--restore-version |
-r |
Required: false. Restore the version number to its original state. |
nsmgr modify-project-version -p ~/myprj/MyPrj.Service/MyPrj.Service.csproj -n 1.15.232
nsmgr modify-project-version -p ~/myprj/MyPrj.Service/MyPrj.Service.csproj -n 1.15.232 -b
nsmgr modify-project-version -p ~/myprj/MyPrj.Service/MyPrj.Service.csproj -r
This feature only applies to C# csproj file only. F# and VB can be catered as well when needs be.
This feature should be open ended. In the future, we can also modify Authors, Copyright, Company, Product, Description and other critical elements.
put in some nice simple graphics upon loading cli
Sometimes, we would want to clear up bin and obj folders to reserve hard disk space. If we have multiple projects lying around in the hard disk, we need to search all folders and delete them. This is time consuming and very much needed to find and delete them manually. Having this 'verb' or command would help to list all bin and obj folders and order them by size, and delete them where necessary.
We can delete these folders since they are usually used for project compilation
The following commands can be used as a starting point for other potential verbs for this purposes:
List out all bin and obj folders under a parent folder
Usage:
nautilus-cli list-binobj-folders --path /users/itsme/projects
Delete all bin and obj folders under a parent folder
Usage:
nautilus-cli delete-binobj-folders --path /users/itsme/projects
Name: synthphonic
Date: 1 June 2022
Github Id (if exists): synthphonic
Automate .csproj to add/update/delete metadata to prepare for nuget package creation
Indirectly, we already have modify-project-version
command in issue https://github.com/synthphonic/nautilus-cli/issues/29 which can already add/update the 'Version' element reside in .csproj under the first PropertyGroup.
We could extend and refactor the code in it to support nuget package elements as well.
<Description>My nuget package.</Description>
<Authors>synthphonic</Authors>
<Owners>the owner1, the owner2</Owners>
<PackageTags>tag1, tag2, tag3</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Copyright>Copyright 2022</Copyright>
<PackageVersion>1.0.0-preview1</PackageVersion>
Project(s) that needs to create nuget package should be able to use this tool with ease to add metadata without going to have to update all csproj file manually.
In order to add/update an element, the following command is needed
format:
Command | Description |
---|---|
nsmgr project-metadata -p ProjectFilePath -m PropertyName:Authors=aa, ab |
add or update property |
nsmgr project-metadata -p ProjectFilePath -m PropertyName:Version=1.1.0.1231 |
add or update property |
nsmgr project-metadata -p ProjectFilePath -m PropertyName:Version -r |
to remove the property |
Property Name | Example |
---|---|
Authors |
author1, author2 |
Description |
Project description |
Owners |
owner1, owner2 |
PackageTags |
tag1, tag2 |
PackageReadmeFile |
README.md |
Copyright |
Copyright MyApp 2022 |
PackageReadmeFile |
README.md |
PackageVersion |
1.0.0-preview1 |
To add or update metadata
nsmgr project-metadata -p /projects/myapp/Project1.csproj -m PropertyGroup:Authors=author1, author2, author3
nsmgr project-metadata -p /projects/myapp/Project1.csproj -m PropertyGroup:Description=The description of the nuget package
To remove a metadata
nsmgr project-metadata -p /projects/myapp/Project1.csproj -m PropertyGroup:Description -r
TBA
TBA
Build and publish for:
To Extract projects inside .sln file
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.