Skip to content
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

Availability as "dotnet tool" #1

Open
nefarius opened this issue May 19, 2023 · 15 comments · Fixed by #2
Open

Availability as "dotnet tool" #1

nefarius opened this issue May 19, 2023 · 15 comments · Fixed by #2

Comments

@nefarius
Copy link
Contributor

nefarius commented May 19, 2023

Hey there!

Would it be feasible to make this available via "dotnet tool" for us Rider plebs? 😉

I tried to be adventurous but that didn't work 😅

dotnet tool install -g Onova.Publisher
C:\Users\nefar\AppData\Local\Temp\e11c2c47-016c-4df1-810b-214dcdf66133\restore.csproj : error NU1212: Invalid project-package combination for Onova.Publi
sher 1.2.4. DotnetToolReference project style can only contain references of the DotnetTool type
The tool package could not be restored.
Tool 'onova.publisher' failed to install. This failure may have been caused by:

* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.

For more reasons, including package naming enforcement, visit https://aka.ms/failure-installing-tool

Thanks, cheers!

EDIT: got curious and started working on #2

@dady8889
Copy link
Owner

Hey, the changes look great.
I didn't know about dotnet tool, nor that you could easily add the dependency to vcpkg like that.
Let me know when you would like me to test it and merge the PR.

@nefarius
Copy link
Contributor Author

nefarius commented May 19, 2023

How are you typically making a new public release? I try to understand why publishing doesn't work on my end.

Also should be teast-ready as well, feel free to!

@dady8889
Copy link
Owner

Usually it goes like this.

  1. Bump the version number in Project Properties
  2. Either call dotnet publish or use the function in your IDE to publish the code to some folder
  3. Now you can use the Onova.Publisher tool, for example
Onova.Publisher --name DummyApp --version 1.3.0 --url https://dummy.com/files/ --target publish\
  1. You can now upload the contents of OnovaPublish to the URL location. (you can change this using --output switch.)
  2. Assuming you have the code for the updating process, you are done and you can install using Setup.exe and update automatically in-app.

I have employed this process in my other project, https://github.com/dady8889/Aniwari/blob/master/publish.ps1.
This script uses VS automation API to get the project info and do the publish steps automatically.

Currently, the Setup.exe doesn't install from GitHub. But it is on todo.

@nefarius
Copy link
Contributor Author

Odd, it doesn't want to work over here but if it works on your end, feel free to bump the version number and prepare a release if you like, I'll set the PR at ready for review. This is what I get:

image

Text copy:

 Onova.Publisher  dotnet publish -c Release
MSBuild version 17.6.0-preview-23174-01+e7de13307 for .NET
D:\Development\GitHub\Onova.Publisher\Onova.Installer\Onova.Installer.vcxproj : warning NU1503: Skipping restore for project 'D:\Development\GitHub\Ono
va.Publisher\Onova.Installer\Onova.Installer.vcxproj'. The project file may be invalid or missing targets required for restore. [D:\Development\GitHub\
Onova.Publisher\Onova.Publisher.sln]
  Determining projects to restore...
C:\Program Files\dotnet\sdk\8.0.100-preview.3.23178.7\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets(28,5): warning NETSDK113
8: The target framework 'net5.0' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/dotnet-core-supp
ort for more information about the support policy. [D:\Development\GitHub\Onova.Publisher\Onova.Publisher\Onova.Publisher.csproj]
  All projects are up-to-date for restore.
D:\Development\GitHub\Onova.Publisher\Onova.Installer\Onova.Installer.vcxproj(28,3): error MSB4019: The imported project "D:\Microsoft.Cpp.Default.prop
s" was not found. Confirm that the expression in the Import declaration "\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
 Onova.Publisher  dotnet publish -c Release .\Onova.Publisher\Onova.Publisher.csproj
MSBuild version 17.6.0-preview-23174-01+e7de13307 for .NET
  Determining projects to restore...
C:\Program Files\dotnet\sdk\8.0.100-preview.3.23178.7\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets(28,5): warning NETSDK113
8: The target framework 'net5.0' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/dotnet-core-supp
ort for more information about the support policy. [D:\Development\GitHub\Onova.Publisher\Onova.Publisher\Onova.Publisher.csproj]
C:\Program Files\dotnet\sdk\8.0.100-preview.3.23178.7\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets(28,5): warning NETSDK113
8: The target framework 'net5.0' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/dotnet-core-supp
ort for more information about the support policy. [D:\Development\GitHub\Onova.Publisher\Onova.Publisher\Onova.Publisher.csproj]
  All projects are up-to-date for restore.
C:\Program Files\dotnet\sdk\8.0.100-preview.3.23178.7\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets(28,5): warning NETSDK113
8: The target framework 'net5.0' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/dotnet-core-supp
ort for more information about the support policy. [D:\Development\GitHub\Onova.Publisher\Onova.Publisher\Onova.Publisher.csproj]
C:\Program Files\dotnet\sdk\8.0.100-preview.3.23178.7\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(287,5): message N
ETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [D:\Development\GitHub\Onova.Publisher\Onova.Publisher\On
ova.Publisher.csproj]
  Onova.Publisher -> D:\Development\GitHub\Onova.Publisher\Onova.Publisher\bin\Onova.Publisher\Release\AnyCPU\net5.0\Onova.Publisher.dll
D:\Development\GitHub\Onova.Publisher\Onova.Publisher\Onova.Publisher.csproj(45,3): error MSB3030: Could not copy the file "*Undefined*bin\Onova.Instal
ler\Release\Win32\Onova.Installer.exe" because it was not found.

@dady8889
Copy link
Owner

Oh, I would like to apologize for the steps before, that is if you want to release a new version of your own app.

When I am preparing a new release for the tool, I first have to compile the installer project in Release/Win32.

Then I just publish the Publisher project as you did with the dotnet publish.

However, in the project I have to copy the installer to the publisher, so there is a macro for this: https://github.com/dady8889/Onova.Publisher/blame/7f18a1300077b1d6665ac7fe2103eae3cf48149e/Onova.Publisher/Onova.Publisher.csproj#LL47C18-L47C18

I think because you don't have the solution open, the macro $(SolutionDir) cannot expand.

I will check the code and make a release, thanks for the contribution.

@nefarius
Copy link
Contributor Author

I think because you don't have the solution open, the macro $(SolutionDir) cannot expand.

IIRC this variable is never populated if you publish using the .csproj directly. Not a biggie though, as long as you're happy with the changes 😉

@nefarius
Copy link
Contributor Author

The PR is ready btw.

@nefarius
Copy link
Contributor Author

Hm, it still can't be consumed as a dotnet tool unfortunately:

dotnet tool install -g -v n Onova.Publisher
Build started 31/05/2023 14:25:20.
     1>Project "C:\Users\nefar\AppData\Local\Temp\0489d449-78f7-42f6-967c-cb9ad5fc659b\restore.csproj" on node 1 (Restore target(s)).
     1>_GetAllRestoreProjectPathItems:
         Determining projects to restore...
       Restore:
         X.509 certificate chain validation will use the default trust store selected by .NET for code signing.
         X.509 certificate chain validation will use the default trust store selected by .NET for timestamping.
         Restoring packages for C:\Users\nefar\AppData\Local\Temp\0489d449-78f7-42f6-967c-cb9ad5fc659b\restore.csproj...
           CACHE https://api.nuget.org/v3-flatcontainer/onova.publisher/index.json
           GET https://baget.vigem.org/v3/package/onova.publisher/index.json
           NotFound https://baget.vigem.org/v3/package/onova.publisher/index.json 174ms
           CACHE https://api.nuget.org/v3-flatcontainer/onova.publisher/1.2.5/onova.publisher.1.2.5.nupkg
         Installed Onova.Publisher 1.2.5 from https://api.nuget.org/v3/index.json with content hash McElQXW6yJMaJR662xMHwwmer5tOMZNQO/s5FrRDMefKafrtGOaUAFzt2Vpw7UaXxPpYw2ugRNfE88DMej7E5A==.
     1>C:\Users\nefar\AppData\Local\Temp\0489d449-78f7-42f6-967c-cb9ad5fc659b\restore.csproj : error NU1212: Invalid project-package combination for Onova.Publisher 1.2.5. DotnetToolReference project style can only contain references of the DotnetTool
        type
         Generating MSBuild file C:\Users\nefar\.dotnet\tools\.store\.stage\wmxfi2pe.ar5\restore.csproj.nuget.g.props.
         Writing assets file to disk. Path: C:\Users\nefar\.dotnet\tools\.store\.stage\wmxfi2pe.ar5\project.assets.json
         Failed to restore C:\Users\nefar\AppData\Local\Temp\0489d449-78f7-42f6-967c-cb9ad5fc659b\restore.csproj (in 549 ms).

         NuGet Config files used:
             C:\Users\nefar\AppData\Roaming\NuGet\NuGet.Config
             C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config
             C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config

         Feeds used:
             https://api.nuget.org/v3/index.json
             C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
             https://baget.vigem.org/v3/index.json
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder

         Installed:
             1 package(s) to C:\Users\nefar\AppData\Local\Temp\0489d449-78f7-42f6-967c-cb9ad5fc659b\restore.csproj
     1>Done Building Project "C:\Users\nefar\AppData\Local\Temp\0489d449-78f7-42f6-967c-cb9ad5fc659b\restore.csproj" (Restore target(s)) -- FAILED.

Build FAILED.

       "C:\Users\nefar\AppData\Local\Temp\0489d449-78f7-42f6-967c-cb9ad5fc659b\restore.csproj" (Restore target) (1) ->
       (Restore target) ->
         C:\Users\nefar\AppData\Local\Temp\0489d449-78f7-42f6-967c-cb9ad5fc659b\restore.csproj : error NU1212: Invalid project-package combination for Onova.Publisher 1.2.5. DotnetToolReference project style can only contain references of the DotnetTo
       ol type

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.08
The tool package could not be restored.
Tool 'onova.publisher' failed to install. This failure may have been caused by:

* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.

For more reasons, including package naming enforcement, visit https://aka.ms/failure-installing-tool

Will do some more digging, weird...

@nefarius
Copy link
Contributor Author

If I build and publish locally and disable the official NuGet feed it works... ❓

dotnet tool install --global --configfile disable_nuget.config --add-source D:\Development\GitHub\Onova.Publisher\Onova.Publisher\publish\ Onova.Publisher
You can invoke the tool using the following command: Onova.Publisher
Tool 'onova.publisher' (version '1.2.5') was successfully installed.

@nefarius
Copy link
Contributor Author

Alright, I've uploaded the .nupkg to my own nuget server and from there the installation works:

dotnet tool install -v n --global --configfile disable_nuget.config --add-source https://baget.vigem.org/v3/index.json Onova.Publisher
Build started 31/05/2023 15:00:06.
     1>Project "C:\Users\nefar\AppData\Local\Temp\87ef2d68-e2c2-4d95-a96d-51a0b86746ad\restore.csproj" on node 1 (Restore target(s)).
     1>_GetAllRestoreProjectPathItems:
         Determining projects to restore...
       Restore:
         X.509 certificate chain validation will use the default trust store selected by .NET for code signing.
         X.509 certificate chain validation will use the default trust store selected by .NET for timestamping.
         Restoring packages for C:\Users\nefar\AppData\Local\Temp\87ef2d68-e2c2-4d95-a96d-51a0b86746ad\restore.csproj...
           CACHE https://baget.vigem.org/v3/package/onova.publisher/index.json
           CACHE https://baget.vigem.org/v3/package/onova.publisher/1.2.5/onova.publisher.1.2.5.nupkg
         Installed Onova.Publisher 1.2.5 from https://baget.vigem.org/v3/index.json with content hash CA8j8+rtlfZmC/IAQsK6XRR1wHlNg1grjNCFOUcziztOG4UTJO17hZZ4qQtUcpQEzdjAyLeGQUwtDlBNaJv6NQ==.
         Generating MSBuild file C:\Users\nefar\.dotnet\tools\.store\.stage\beta5chl.hn1\restore.csproj.nuget.g.props.
         Writing assets file to disk. Path: C:\Users\nefar\.dotnet\tools\.store\.stage\beta5chl.hn1\project.assets.json
         Restored C:\Users\nefar\AppData\Local\Temp\87ef2d68-e2c2-4d95-a96d-51a0b86746ad\restore.csproj (in 255 ms).

         NuGet Config files used:
             C:\Users\nefar\disable_nuget.config

         Feeds used:
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder
             https://baget.vigem.org/v3/index.json

         Installed:
             1 package(s) to C:\Users\nefar\AppData\Local\Temp\87ef2d68-e2c2-4d95-a96d-51a0b86746ad\restore.csproj
     1>Done Building Project "C:\Users\nefar\AppData\Local\Temp\87ef2d68-e2c2-4d95-a96d-51a0b86746ad\restore.csproj" (Restore target(s)).

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.82
You can invoke the tool using the following command: Onova.Publisher
Tool 'onova.publisher' (version '1.2.5') was successfully installed.

I wonder what the difference is here 🤔

@nefarius
Copy link
Contributor Author

Pardon the spam but I think we need to pull this release; I just dissected the .nupkg and what happens on installation and it appears that due to limitations with dotnet tool I wasn't aware of before the native tools like signtool.exe and Onova.Installer.exe were not packaged, they are also missing after extraction:

image

My bad mate, should've tested this more thoroughly 😦

@nefarius
Copy link
Contributor Author

Working on a new branch to fix that 😅

image

@nefarius
Copy link
Contributor Author

Alright, progress 💪

Install tool

dotnet tool install -v n --global --configfile C:\Users\nefar\disable_nuget.config --add-source .\Onova.Publisher\publish\ Onova.Publisher
Build started 31/05/2023 16:31:23.
     1>Project "C:\Users\nefar\AppData\Local\Temp\8bb998c1-4f72-4dee-8cc6-a23b4add553e\restore.csproj" on node 1 (Restore target(s)).
     1>_GetAllRestoreProjectPathItems:
         Determining projects to restore...
       Restore:
         X.509 certificate chain validation will use the default trust store selected by .NET for code signing.
         X.509 certificate chain validation will use the default trust store selected by .NET for timestamping.
         Restoring packages for C:\Users\nefar\AppData\Local\Temp\8bb998c1-4f72-4dee-8cc6-a23b4add553e\restore.csproj...
         Installed Onova.Publisher 1.2.6 from D:\Development\GitHub\Onova.Publisher\Onova.Publisher\publish\ with content hash M5weqGhbHxwF81wNUhOXCmMkZD+QadiWn+UwCo8TnDVXQZAP50iCCNDvy+J1uCDV2ORJ1xDXY7fNsN36wG1lbg==.
         Generating MSBuild file C:\Users\nefar\.dotnet\tools\.store\.stage\3rylznqc.q11\restore.csproj.nuget.g.props.
         Writing assets file to disk. Path: C:\Users\nefar\.dotnet\tools\.store\.stage\3rylznqc.q11\project.assets.json
         Restored C:\Users\nefar\AppData\Local\Temp\8bb998c1-4f72-4dee-8cc6-a23b4add553e\restore.csproj (in 276 ms).

         NuGet Config files used:
             C:\Users\nefar\disable_nuget.config

         Feeds used:
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder
             D:\Development\GitHub\Onova.Publisher\Onova.Publisher\publish\

         Installed:
             1 package(s) to C:\Users\nefar\AppData\Local\Temp\8bb998c1-4f72-4dee-8cc6-a23b4add553e\restore.csproj
     1>Done Building Project "C:\Users\nefar\AppData\Local\Temp\8bb998c1-4f72-4dee-8cc6-a23b4add553e\restore.csproj" (Restore target(s)).

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.87
You can invoke the tool using the following command: Onova.Publisher
Tool 'onova.publisher' (version '1.2.6') was successfully installed.

Installed tool extracted location

image

Publishing a test application

Onova.Publisher --name NAC --version 1.0.0 --url https://apps.nefarius.at/files/ --target .\setup\publish\x64\
Publishing application NAC...
WARNING: File NAC-1.0.0.zip will be overwritten.
Resuming in 3 seconds...
Creating zip...
Building installer...
Successfully published NAC version 1.0.0 into NAC-1.0.0.zip.

Doing more comprehensive testing now 🖖

@nefarius
Copy link
Contributor Author

@dady8889 pardon me, took me some time but it is finally resolved! Please see in #3, cheers!

@dady8889
Copy link
Owner

I see, will look into it. Btw, I unpacked 1.2.5 and the files are still there, so I am leaving it up.

@dady8889 dady8889 reopened this Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants