Skip to content

Commit 93677e9

Browse files
authored
add choco packaging guide
1 parent d67ea65 commit 93677e9

File tree

1 file changed

+85
-1
lines changed

1 file changed

+85
-1
lines changed

doc/dev_guide/packaging.md

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,91 @@ TODO Instructions
2626

2727
## Chocolatey
2828

29-
TODO Instructions
29+
### Step 1: Setup Skeleton
30+
31+
First step towards making a choco package is initializing a base.
32+
33+
The command `choco new -h` can teach you more about the `new` command, its usage, options, switches, and exit codes.
34+
35+
Run the following command to setup the base
36+
37+
```powershell
38+
choco new --name="apidash" --version="0.3.0" maintainername="foss42" maintainerrepo="https://github.com/foss42/apidash" --built-in-template
39+
```
40+
41+
![choco folder structure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lzxebtal5tt1u2o4n5hp.png)
42+
43+
This creates the following folder structure
44+
45+
```
46+
apidash
47+
├── ReadMe.md
48+
├── _TODO.txt
49+
├── apidash.nuspec
50+
└── tools
51+
├── chocolateybeforemodify.ps1
52+
├── chocolateyinstall.ps1
53+
├── chocolateyuninstall.ps1
54+
├── LICENSE.txt
55+
└── VERIFICATION.txt
56+
```
57+
58+
The files `ReadMe.md` and `_TODO.md` can be deleted before pushing.
59+
60+
The files of our main interest are `chocolateyinstall.ps1` and `apidash.nuspec`.
61+
62+
### Step 2: Editing `chocolateyinstall.ps1`
63+
64+
Take a look at `chocolateyinstall.ps1` file. There are many comments stating the use case of each line itself.
65+
![chocolatelyinstall.ps1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/boc5lcstslju2qtey9cm.png)
66+
67+
Comments can bre remoed using the following command.
68+
```powershell
69+
$f='apidash\tools\chocolateyinstall.ps1'
70+
gc $f | ? {$_ -notmatch "^\s*#"} | % {$_ -replace '(^.*?)\s*? [^``]#.*','$1'} | Out-File $f+".~" -en utf8; mv -fo $f+".~" $f
71+
```
72+
73+
74+
Now our `chocolateyinstall.ps1` file is ready.
75+
76+
### Step 3: Editing `apidash.nuspec`
77+
78+
![final apidash.nuspec](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2km555bocw3upnkulj1y.png)
79+
80+
### Step 4: Build the package
81+
82+
All our files are ready, we just need to pack out files in a choco package with the extension `.nupkg`.
83+
84+
Run the following command from the root of your directory:
85+
```powershell
86+
choco pack
87+
```
88+
This command generates the `apidash.0.3.0.nupkg` file.
89+
90+
### Step 5: Test the Package Locally
91+
92+
Install the package locally using Chocolatey:
93+
```powershell
94+
choco install apidash -s .
95+
```
96+
Ensure the application installs correctly.
97+
98+
![Shell output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/98yzsrhm1tnld8ylatt3.png)
99+
100+
### Step 6: Pre-Publishing - Update `LICENSE.txt` & `VERIFICATION.txt`
101+
102+
Update `LICENSE.txt` with the actual **LICENSE **and `VERIFICATION.txt` accordingly.
103+
104+
### Step 7: Publish the Package (Optional)
105+
106+
To share the package, you can push it to a Chocolatey repository. For the official Chocolatey Community Repository, follow these steps:
107+
108+
1. Create an account on the Chocolatey Community.
109+
2. Get an API key by navigating to your profile.
110+
3. Use the following command to push your package:
111+
```powershell
112+
choco push apidash.0.3.0.nupkg --source="https://push.chocolatey.org/" --api-key="YOUR_API_KEY"
113+
```
30114

31115
## WinGet
32116

0 commit comments

Comments
 (0)