Skip to content

dotnet tool --install Should Insert In a Deterministic Order #14693

Open
@aolszowka

Description

As it says on the tin: dotnet tool --install should insert tools into dotnet-tools.json in some type of deterministic order (I suggest via some type of alphabetical/pseudo-alphabetical order).

Our use case involves us with several 10's of dotnet tool packages (more every day as we dive in deeper into the system). Due to the size of our code base and multiple branches we work hard to avoid merge conflicts resulting in the race to push.

When dealing with dotnet tool it is frustrating to have to work around the non-deterministic ordering when inserting new tools due to the various merge conflicts that arise.

Steps to Reproduce

dotnet new tool-manifest
dotnet tool install dotnet-format
dotnet tool install dotnet-dump

Expected Result

{
  "version": 1,
  "isRoot": true,
  "tools": {
    "dotnet-dump": {
      "version": "5.0.152202",
      "commands": [
        "dotnet-dump"
      ]
    },
    "dotnet-format": {
      "version": "4.1.131201",
      "commands": [
        "dotnet-format"
      ]
    }
  }
}

Instead as of:

dotnet --version
5.0.100

This still inserts in whatever order we happen to do.

In addition I cannot recall if JSON requires that the comma for an array be on the same line, but if that is not required it'd be great to not have that, this way when you add to the last element you don't get a garbage merge conflict due to , being added.

Work Arounds

Since its just a JSON file you can use any JSON sorting abilities you have, or baring that we rebuild the entire file by dumping the installed tools, sorting based on name, and then readding them (not super efficient, but good enough).

Thank you

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions