Coder Social home page Coder Social logo

synthphonic / nsmgr-cli Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 142.93 MB

nautilus-cli or nautilus solution manager (nsmgr) is an open source cli tool to help developers to maintain their solution and projects in it.

C# 96.34% PowerShell 3.66%

nsmgr-cli's People

Contributors

synthphonic avatar

Watchers

 avatar  avatar  avatar

nsmgr-cli's Issues

Update csproj and packages.json files to change nuget version package accordingly

Specification

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

Summary

In short, when the command line is run successfully, a successful result will be of the following:

  1. The nuget package version that resides in csproj/packages.config file for the particular project is updated accordingly

command: findconflict to have an autoupdate switch

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

command: list-projects

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}

Output report to file for exceptions

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.

Make Fluent API for Command creation

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

BUG - Method not implemented exception was thrown when trying to find a nuget package for older targeted net framework versions

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`

update-nuget-packages for all projects that depends on the intended nuget package

Description

  • This feature is already made available in Visual Studio - in the Consolidation tab and the Updates tab
  • nuget cli also has this feature.
  • dotnet cli also has this feature (if im not mistaken)

Why this feature?

  • As an option to use nsmgr to update a package version in csproj
  • fast (i think)

Drawbacks

  • need to run dotnet restore at the solution level once the package is updated in the csproj file

list-projects verb throws an exception

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, Dictionary2 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

Command to list out TargetFrameworks for a particular solution

Info

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.

Command and Options Suggestion

list-targetframeworks -s ~/projects/xxx.sln

Nautilus Solution Manager cli tool is able to change a particular C# project version accordingly

Feature By

Name: szs
Date: 24 May 2022
Repository Handle (if exists): github.com/synthphonic

Description

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.

Screenshot 2022-05-24 at 5 52 39 PM

nsmgr cli tool should be able to cater for this modification with ease

Current Behavior

Not available

Expected Behavior

  • When modifying a version, the cli should keep the original version number in case if the user wishes to rollback to its original version number.

Details

  • Command: modify-project-version
  • Description: Modify a particular C# project version accordingly"

Options

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.

Potential Usage

Change version

nsmgr modify-project-version -p ~/myprj/MyPrj.Service/MyPrj.Service.csproj -n 1.15.232

Change version with csproj file back

nsmgr modify-project-version -p ~/myprj/MyPrj.Service/MyPrj.Service.csproj -n 1.15.232 -b

Restore original version of the csproj file

nsmgr modify-project-version -p ~/myprj/MyPrj.Service/MyPrj.Service.csproj -r

Prerequisites

This feature only applies to C# csproj file only. F# and VB can be catered as well when needs be.

Other Suggestions

This feature should be open ended. In the future, we can also modify Authors, Copyright, Company, Product, Description and other critical elements.

[Feature] A feature to list and find the sizes for all 'bin' and 'obj' folders

Description

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-binobj-folders
  • delete-binobj-folders

list-binobj-folders

List out all bin and obj folders under a parent folder
Usage:

nautilus-cli list-binobj-folders --path /users/itsme/projects
  • path : Required. The targeted full path to list all bin and obj folders.

delete-binobj-folders

Delete all bin and obj folders under a parent folder
Usage:

nautilus-cli delete-binobj-folders --path /users/itsme/projects
  • path : Required. The targeted full path to delete all bin and obj folders.

Ability to add/update/delete csproj file metadata related to nuget package creation

Feature By

Name: synthphonic
Date: 1 June 2022
Github Id (if exists): synthphonic

Description

Automate .csproj to add/update/delete metadata to prepare for nuget package creation

Current Behavior

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>

Expected Behavior

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.

Potential Command name and Parameters

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

Supported Properties

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

Examples

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

Prerequisites

TBA

Other Suggestions

TBA

Extract solution (.sln) file

To Extract projects inside .sln file

  • Extract project name
  • Extract project relative path to the sln file
  • Extract project GUID
  • Extract TypeGuid (Folder, C# etc)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.