-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added dotnet tool support #12
Conversation
I'm open to it and happy to merge a good PR (one commit per one thing, well-described) if it makes sense and there's a benefit to it. I don't mind changing the way the package is built, if the end result is the same (or at least the same for practical purposes) and you do the work of updating the actions. I do not however understand why would this be desirable in the first place (the link you provided doesn't really explain it) instead of simply calling the tools directly from the package. So understanding that is a prerequisite. |
src/.gitignore
Outdated
@@ -0,0 +1,398 @@ | |||
## Ignore Visual Studio temporary files, build results, and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes are both unrelated to the commit message and pointless - don't use generated ignore files that don't apply to the project in question!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have moved the needed ignore path to the root gitignore file
src/Gettext.Tools/Program.cs
Outdated
Console.WriteLine("Usage:"); | ||
Console.WriteLine(" Gettext.Tools -- <TOOL_NAME> [tool specific options]"); | ||
Console.WriteLine(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand how to use it from this help. It would be good to add some documentation to the readme file too...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added more information to the usage output and additionally added a readme.md file for the dotnet tool nuget package.
I do not had the intention that this PR is merged "As-Is". I just want to discuss how, if it makes sense and whether you are even want to add support for dotnet tool in advance before putting effort into this. Admittedly, this was not clearly written. The link I provided is the documentation for how a dotnet tool nuget package can be setup, built and run. A good article about what a dotnet tool is and why to use dotnet tools can be found e.g. here. My use case is the following: I have a project from which I extract the translateable string with the PoExtractor - which is also a dotnet tool - and afterwards merge / filter / ... the extracted pot/po files with the gettext tools. All of this can be done with a dotnet-tools.json file which describes the tools needed and a batch script that ensures that the dependencies are installed (dotnet tool restore) and then doing its work. Why not calling the tools directly from the package? |
This is a preparation for adding dotnet tool support for this nuget package. All metadata is moved from the Gettext.Tools.nuspec to the Directory.Build.props file which gets applied to all projects on a lower directory level. A new project src/Gettext.Tools was introduced which contains the package id and additional files that are only needed for the nuget PackageType "reference". Additionally, the project is used to build the nuget package with the "dotnet pack" command which is now used by the Makefile. The resulting package is exactly the same as if it was created with the nuspec file.
With these changes, the Gettext.Tools can additionally be installed as a dotnet tool. This makes it possible to install it as global tool and directly use it from the command line. A dotnet tool can register only a single command. Therefore, the gettext tool itself must be passed as a parameter, including individual options, to the "top-level" Gettext.Tools command. e.g. Gettext.Tools -- <TOOL_NAME> [tool specific options] It was needed to create a separate nuget package for the tools functionality as the PackAsTool property removes all other package types from the generated nuspec file.
3a1294b
to
872d215
Compare
I have cleaned up the PR now. It seems not to be possible to create a nuget package with both DotNetTool and default Reference package type when using the PackAsTool property. As soon as I have added the PackAsTool property, all other package types get removed from the generated nuspec file. As a consequence, I have added a separate nuget package configuration for now. The addtional nuget package is build by the Makefile target nuget. But I did not have added it to the publish target yet. To check if the original package did not have changed by the new tooling, I have extracted the new package content on the original one (which I have tracked with git). These are the only differences: |
The GitHub Actions build is failing due to missing I am confused by this:
You say the package didn't change, but you also say it is of some different kind now? And that there will need to be two published packaged, or do you mean something else? I'm OK with merging this, but it's unclear to me if my requirement that the new packages will be drop-in replacement for the old ones, i.e. backward compatible, is met? |
The current package did not change, it can be a drop-in replacement for the current package. This is because I have not changed anything except that the package is built with This was the preparation for adding dotnet tool support in a second step. According to the documentation multiple package types can be set for one nuget package. Therefore, my intention was to just add the additional Package Type DotnetTool to the original nuget package. But as my tests have shown it is not possible to set both, Dependency and DotnetTool for one nuget package - although I could not find anything about that restriction in the Microsoft documentation. As a consequence, I have not changed the "original" nuget package (except moving from nuget pack to dotnet pack), but have added a second nuget package which reuses all the nuget package meta information and of course the gettext-tools binaries and pack that as nuget package with PackageType DotnetTool. In my opinion this could/should be released in parallel with the original nuget package because it has in fact the same content as the original package only with a different use case, namely using it as dotnet tool.
Ok I have to check that. Never have done something with the Github Build Pipeline. |
This was not clear to me. And it's still not clear to me what is the new package created, how is it named, published etc. I'm hesitant to maintain two packages just for the sake of this... If it's something I can easily add to the existing package, I'm all for merging it (it's not useful to me, but if it's other, why not), but if it's more maintenance work in the future, and more confusion, that's less clear to me. And if I should provide different kinds of packages (which can be argued), why dotnet tool in particular, when e.g. winget or chocolatey seem more widespread? |
I will reopen this again, as soon as multiple package types are supported as documented- which is not the case at the moment. |
Hi,
I want to ask what do you think about adding support for using the nuget also as dotnet tool. So running it with
dotnet tool run
as described here.I have added a basic initial implementation (which you can see in the PR) that works fine for me. The question is, can we get rid of the Gettext.Tools.nuspec file because for the dotnet tool to work, a project file must be used where the nuget information must/can be added. At the moment the information is just duplicated and the project must be packed with
dotnet pack
Afterwards, the tools nuget can for instance be used like:
What do you think about it? Are you able to integrate that in a clean way? Or do you have suggestions how I can integrate it in a more clean way?