Skip to content

Commit

Permalink
Merge pull request #37
Browse files Browse the repository at this point in the history
Kickstart development of powershell module
  • Loading branch information
svrooij authored Apr 2, 2024
2 parents 6f15dab + 3a5c8d3 commit 763a5a9
Show file tree
Hide file tree
Showing 94 changed files with 6,082 additions and 1,349 deletions.
80 changes: 54 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
name: CI for WingetIntune
name: 🏗️🧪📦 WinTuner

on:
push:
branches:
- main
- dev
#- feature/*
tags:
- v*
pull_request:
branches:
- main
- dev
workflow_dispatch:

jobs:
Expand All @@ -22,18 +21,18 @@ jobs:
checks: write
steps:
- name: 👨‍💻 Check-out code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 👨‍🔧 Setup .NET Core SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.x
dotnet-version: 8.x

- name: 🔍 Enable problem matchers
run: echo "::add-matcher::.github/matchers/dotnet.json"

- name: 🦸‍♂️ Restore steriods
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
Expand Down Expand Up @@ -62,35 +61,27 @@ jobs:
if: always()
run: dotnet format --verify-no-changes

publish:
name: 📦 Publish nuget library
publish-nuget:
name: 📦 Publish WinTuner to nuget
runs-on: ubuntu-latest
if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/dev') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
if: startsWith(github.ref, 'refs/tags/')
needs: [test]
steps:
- name: 👨‍💻 Check-out code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 👨‍🔧 Setup .NET Core SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.x

- name: 🛠️ Compute version with GitVersion
run: |
dotnet tool install --global GitVersion.Tool --version 5.*
echo "## 📦 Calculated version" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
dotnet-gitversion /updateprojectfiles /output buildserver /nofetch
dotnet-gitversion /nofetch /output json /showvariable NuGetVersionV2 >> $GITHUB_STEP_SUMMARY
dotnet-version: 8.x

- name: 🔍 Enable problem matchers
run: echo "::add-matcher::.github/matchers/dotnet.json"

- name: 🦸‍♂️ Restore steriods
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
Expand All @@ -102,12 +93,49 @@ jobs:
run: dotnet restore

- name: 🛠️ Build code
run: dotnet build --configuration Release --no-restore
shell: pwsh
run: dotnet build ./src/WingetIntune.Cli/WingetIntune.Cli.csproj --configuration Release --no-restore -p:Version=$("${{ github.ref_name }}".Substring(1))

- name: 📦 Pack WingetIntune CLI
run: dotnet pack --configuration Release --no-build --no-restore ./src/WingetIntune.Cli/WingetIntune.Cli.csproj
- name: 📦 Pack WinTuner CLI
shell: pwsh
run: dotnet pack ./src/WingetIntune.Cli/WingetIntune.Cli.csproj --configuration Release --no-build -p:Version=$("${{ github.ref_name }}".Substring(1))

- name: ✈️ Publish Svrooij.Winget-Intune.Cli to nuget.org
run: dotnet nuget push ./src/WingetIntune.Cli/bin/Release/SvRooij.Winget-Intune.Cli.*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}

publish-psgallery:
name: 📦 Publish WinTuner to PowerShell Gallery
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: [test]
steps:
- name: 👨‍💻 Check-out code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 👨‍🔧 Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x

- name: 🔍 Enable problem matchers
run: echo "::add-matcher::.github/matchers/dotnet.json"

- name: 🦸‍♂️ Restore steriods
uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: 🎒 Load packages
run: dotnet restore

- name: 🛠️ Build code
shell: pwsh
run: dotnet build ./src/Svrooij.WinTuner.CmdLets/Svrooij.WinTuner.CmdLets.csproj --configuration Release --no-restore -p:Version=$("${{ github.ref_name }}".Substring(1))
32 changes: 32 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "PowerShell Launch Current File",
"type": "PowerShell",
"request": "launch",
"script": "${file}",
"cwd": "${fileDirname}"
},
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "dotnet: build-cli",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/WingetIntune.Cli/bin/Debug/net8.0/WingetIntune.Cli.dll",
"args": [
"update",
"list",
"--username", "[email protected]"
],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
}
]
}
15 changes: 15 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "dotnet: build-cli",
"command": "dotnet build ${workspaceFolder}/src/WingetIntune.Cli/WingetIntune.Cli.csproj",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$msCompile"
}
]
}
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Winget Intune packager CLI
# WinTuner CLI

[![GitHub issues](https://img.shields.io/github/issues/svrooij/wingetintune?style=for-the-badge)](https://github.com/svrooij/WingetIntune/issues)
[![Github sponsors](https://img.shields.io/github/sponsors/svrooij?style=for-the-badge&logo=github&logoColor=white)](https://github.com/sponsors/svrooij)

[Documentation](https://wintuner.app/)

Take any (just msi installers for now) app from winget and upload it to Intune in minutes.

- Downloading the installer and the logo
Expand All @@ -16,20 +18,19 @@ Some commands run the `winget` in the background and are thus Windows-only, make
The `package` and `publish` commands are cross-platform, and should work on any platform that supports dotnet 7. These commands no longer use the winget executable, which also means any other sources than `winget` are no longer supported.
The `msi` command is still windows only, as it uses the `Microsoft.Deployment.WindowsInstaller` package.


[![LinkedIn Profile][badge_linkedin]][link_linkedin]
[![Link Mastodon][badge_mastodon]][link_mastodon]
[![Follow on Twitter][badge_twitter]][link_twitter]
[![Check my blog][badge_blog]][link_blog]

## Installing

This package can be downloaded as a dotnet tool. Make sure you have Dotnet 7 installed on your computer.
This package can be downloaded as a dotnet tool. Make sure you have Dotnet 8 installed on your computer.
I'm working to get a code signing certificate, but for now you might have to configure an exception on your computer to run unsigned code.

```Shell
# Install dotnet 7 sdk (or the way specific for your platform)
winget install --id Microsoft.DotNet.SDK.7 --source winget
# Install dotnet 8 sdk (or the way specific for your platform)
winget install --id Microsoft.DotNet.SDK.8 --source winget

# Add the nuget feed, if that is not already done
dotnet nuget add source https://api.nuget.org/v3/index.json --name nuget.org
Expand All @@ -53,10 +54,10 @@ The CLI has several commands, try them out yourself.

```Shell
Description:
winget-intune by @svrooij allows you to package any winget app for Intune
wintuner by @svrooij allows you to package any winget app for Intune

Usage:
winget-intune [command] [options]
wintuner [command] [options]

Options:
--version Show version information
Expand All @@ -80,14 +81,14 @@ You can also expect a `detection.ps1` file, that you should configure to be used
It will also write a `app.json` file with all the information about the app, for automation purposes.
```Shell
winget-intune package {PackageId} [--version {version}] [--source winget] --package-folder {PackageFolder}
wintuner package {PackageId} [--version {version}] [--source winget] --package-folder {PackageFolder}
```
> The `packageId` ~~is case sensitive, so make sure you use the correct casing~~ will be matches against any package in the open source [index](https://github.com/svrooij/winget-pkgs-index). Tip: Copy it from the result of the `winget search {name}` command.
> The `packageId` ~~is case sensitive, so make sure you use the correct casing~~ will be matches against any package in the open source [index](https://wintuner.app/docs/related/winget-package-index). Tip: Copy it from the result of the `winget search {name}` command.
Upon downloading the installer, the SHA256 hash is checked against the one in the `winget` manifest, to make sure you won't package a tampered installer.

The packaging command uses an open-source & cross-platform [implementation](https://github.com/Svrooij/ContentPrep) of the Windows-only & closed source [content-prep-tool](https://github.com/Microsoft/Microsoft-Win32-Content-Prep-Tool), to allow cross-platform building of the packages.
The packaging command uses an open-source & cross-platform [implementation](https://wintuner.app/docs/related/content-prep-tool) of the Windows-only & closed source [content-prep-tool](https://github.com/Microsoft/Microsoft-Win32-Content-Prep-Tool), to allow cross-platform building of the packages.
This new implementation is available as a dotnet library and a PowerShell module, so if you're into Intune packaging, check it out.
### Publish
Expand All @@ -97,10 +98,10 @@ Not all packages will work for publishing, you can always try to manually upload

```Shell
# This app uses the built-in windows authentication, this will trigger a login prompt (or do sso).
winget-intune publish {PackageId} --package-folder {PackageFolder} --tenant {TenantId} --username {Username}
wintuner publish {PackageId} --package-folder {PackageFolder} --tenant {TenantId} --username {Username}
# You can also provide a token, this is useful for automation.
winget-intune publish {PackageId} --package-folder {PackageFolder} --token {Token}
wintuner publish {PackageId} --package-folder {PackageFolder} --token {Token}
```

#### Assignement and categories
Expand All @@ -109,22 +110,22 @@ You can also assign the app to a group, and set the categories.

```Shell
# Add --category "Productivity" --category "Utilities" to the command to set the categories (use the exact name!)
winget-intune publish {PackageId} ... --category "Productivity" --category "Utilities"
wintuner publish {PackageId} ... --category "Productivity" --category "Utilities"
# Add --available "group-guid" to make the app available to a group (use the guid of the group)
# Add --available "allusers" to make the app available to all users
# Instead of --available you can also use --required to make the app required for the group
# Or if you want to remove the app for that group, use --uninstall
winget-intune publish {PackageId}... --required "3bac8336-623f-46bf-bcab-b5c61e3e5b7a" --required "allusers"
winget-intune publish {PackageId}... --uninstall "3bac8336-623f-46bf-bcab-b5c61e3e5b7a" --uninstall "allusers"
wintuner publish {PackageId}... --required "3bac8336-623f-46bf-bcab-b5c61e3e5b7a" --required "allusers"
wintuner publish {PackageId}... --uninstall "3bac8336-623f-46bf-bcab-b5c61e3e5b7a" --uninstall "allusers"
```

#### Auto-package

You can also combine the `package` and `publish` command into one command, this will package the app and publish it to Intune. But this makes debugging harder, so when submitting issues, please don't use this option.
```Shell
winget-intune publish {PackageId}... --auto-package
wintuner publish {PackageId}... --auto-package
```
## Library (soon)
Expand All @@ -137,10 +138,10 @@ If you want to contribute to this project, please check out the [contributing](h

## Usefull information

- [WinTuner website](https://wintuner.app/)
- [Blog articles on Intune](https://svrooij.io/tags/intune/)
- Open-source [winget index](https://github.com/svrooij/winget-pkgs-index/)
- Open-source [PowerShell Content Prep](https://github.com/svrooij/contentprep)
- Closed source [Microsoft Win32 Content Prep tool](https://github.com/microsoft/Microsoft-Win32-Content-Prep-Tool)
- Open-source [winget index](https://wintuner.app/docs/related/winget-package-index)
- Open-source [PowerShell Content Prep](https://wintuner.app/docs/related/content-prep-tool)

[badge_blog]: https://img.shields.io/badge/blog-svrooij.io-blue?style=for-the-badge
[badge_linkedin]: https://img.shields.io/badge/LinkedIn-stephanvanrooij-blue?style=for-the-badge&logo=linkedin
Expand Down
43 changes: 31 additions & 12 deletions WingetIntune.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,28 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{0D5E
scripts\detection-without-version.ps1 = scripts\detection-without-version.ps1
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Winget.CommunityRepository", "src\Winget.CommunityRepository\Winget.CommunityRepository.csproj", "{C0984E0C-FF44-442C-A386-3A53C6670E2B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Winget.CommunityRepository", "src\Winget.CommunityRepository\Winget.CommunityRepository.csproj", "{C0984E0C-FF44-442C-A386-3A53C6670E2B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WingetIntune.Tests", "tests\WingetIntune.Tests\WingetIntune.Tests.csproj", "{A0ACA653-C1FF-4C98-AABC-7FB154D626E1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WingetIntune.Cli", "src\WingetIntune.Cli\WingetIntune.Cli.csproj", "{C32DB1BC-299E-4742-8372-278C8843026C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DF47944D-435C-4C46-B2F5-B7F939F069E6}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{DF47944D-435C-4C46-B2F5-B7F939F069E6}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.github\workflows\build.yml = .github\workflows\build.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "http-requests", "http-requests", "{142B288C-B1E8-4A76-92CE-1D2459CD20C9}"
ProjectSection(SolutionItems) = preProject
graph-apps.http = graph-apps.http
http-requests\test.txt = http-requests\test.txt
EndProjectSection
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{70C0FC9B-4495-43AC-AB67-331201AEAA52}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Svrooij.WinTuner.CmdLets", "src\Svrooij.WinTuner.CmdLets\Svrooij.WinTuner.CmdLets.csproj", "{050B8AB3-6232-4220-950F-578D9E3E2203}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{4E745B8F-95AD-42CC-A462-EBA6896413E2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Winget.CommunityRepository.Ef", "src\Winget.CommunityRepository.Ef\Winget.CommunityRepository.Ef.csproj", "{516169B3-872B-443B-8736-27E2A08E7091}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Apps", "Apps", "{4D1367F6-2076-481E-A7BD-0BFA6BEFCA3D}"
EndProject

Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -40,6 +43,10 @@ Global
{95A3AF98-E99D-40E2-922F-691A769D0FC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{95A3AF98-E99D-40E2-922F-691A769D0FC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{95A3AF98-E99D-40E2-922F-691A769D0FC2}.Release|Any CPU.Build.0 = Release|Any CPU
{C0984E0C-FF44-442C-A386-3A53C6670E2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0984E0C-FF44-442C-A386-3A53C6670E2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0984E0C-FF44-442C-A386-3A53C6670E2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0984E0C-FF44-442C-A386-3A53C6670E2B}.Release|Any CPU.Build.0 = Release|Any CPU
{A0ACA653-C1FF-4C98-AABC-7FB154D626E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0ACA653-C1FF-4C98-AABC-7FB154D626E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0ACA653-C1FF-4C98-AABC-7FB154D626E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -48,14 +55,26 @@ Global
{C32DB1BC-299E-4742-8372-278C8843026C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C32DB1BC-299E-4742-8372-278C8843026C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C32DB1BC-299E-4742-8372-278C8843026C}.Release|Any CPU.Build.0 = Release|Any CPU
{C0984E0C-FF44-442C-A386-3A53C6670E2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0984E0C-FF44-442C-A386-3A53C6670E2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0984E0C-FF44-442C-A386-3A53C6670E2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0984E0C-FF44-442C-A386-3A53C6670E2B}.Release|Any CPU.Build.0 = Release|Any CPU
{050B8AB3-6232-4220-950F-578D9E3E2203}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{050B8AB3-6232-4220-950F-578D9E3E2203}.Debug|Any CPU.Build.0 = Debug|Any CPU
{050B8AB3-6232-4220-950F-578D9E3E2203}.Release|Any CPU.ActiveCfg = Release|Any CPU
{050B8AB3-6232-4220-950F-578D9E3E2203}.Release|Any CPU.Build.0 = Release|Any CPU
{516169B3-872B-443B-8736-27E2A08E7091}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{516169B3-872B-443B-8736-27E2A08E7091}.Debug|Any CPU.Build.0 = Debug|Any CPU
{516169B3-872B-443B-8736-27E2A08E7091}.Release|Any CPU.ActiveCfg = Release|Any CPU
{516169B3-872B-443B-8736-27E2A08E7091}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{95A3AF98-E99D-40E2-922F-691A769D0FC2} = {70C0FC9B-4495-43AC-AB67-331201AEAA52}
{C0984E0C-FF44-442C-A386-3A53C6670E2B} = {70C0FC9B-4495-43AC-AB67-331201AEAA52}
{A0ACA653-C1FF-4C98-AABC-7FB154D626E1} = {4E745B8F-95AD-42CC-A462-EBA6896413E2}
{C32DB1BC-299E-4742-8372-278C8843026C} = {4D1367F6-2076-481E-A7BD-0BFA6BEFCA3D}
{050B8AB3-6232-4220-950F-578D9E3E2203} = {4D1367F6-2076-481E-A7BD-0BFA6BEFCA3D}
{516169B3-872B-443B-8736-27E2A08E7091} = {70C0FC9B-4495-43AC-AB67-331201AEAA52}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {94A78033-8BE6-4A61-BC28-66CE040924C8}
EndGlobalSection
Expand Down
Loading

0 comments on commit 763a5a9

Please sign in to comment.