Skip to content

Commit 811ed76

Browse files
committed
Initial commit: IoTPowerShellAgent open source release
0 parents  commit 811ed76

94 files changed

Lines changed: 57368 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/build-dev.yml‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Build & Test (Dev)
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
tags-ignore:
8+
- "v*.*.*"
9+
pull_request:
10+
11+
jobs:
12+
build:
13+
runs-on: windows-latest
14+
permissions:
15+
contents: read
16+
checks: write
17+
pull-requests: write
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0 # Fetch all history for semantic versioning
22+
23+
- uses: actions/setup-dotnet@v4
24+
with:
25+
global-json-file: global.json
26+
27+
- name: Determine version from Git tag
28+
id: version
29+
run: |
30+
$tag = git describe --tags --abbrev=0 2>$null
31+
if ($tag) {
32+
$version = $tag -replace '^v', ''
33+
if ($version -notmatch '^\d+\.\d+') {
34+
$version = "0.0.0-$version"
35+
}
36+
Write-Host "Version from tag: $version"
37+
echo "version=$version" >> $env:GITHUB_OUTPUT
38+
} else {
39+
Write-Host "No tag found, using default version"
40+
echo "version=1.0.0" >> $env:GITHUB_OUTPUT
41+
}
42+
shell: pwsh
43+
44+
- name: Restore dependencies
45+
run: dotnet restore src\IoTPowerShellAgent\IoTPowerShellAgent.csproj
46+
47+
- name: Build
48+
run: dotnet build src\IoTPowerShellAgent\IoTPowerShellAgent.csproj --configuration Debug /p:Version=${{ steps.version.outputs.version }}

‎.github/workflows/build-prod.yml‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build & Test (Prod)
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
runs-on: windows-latest
12+
permissions:
13+
contents: read
14+
checks: write
15+
pull-requests: write
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- uses: actions/setup-dotnet@v4
22+
with:
23+
global-json-file: global.json
24+
25+
- name: Determine version from Git tag
26+
id: version
27+
run: |
28+
$tag = git describe --tags --abbrev=0 2>$null
29+
if ($tag) {
30+
$version = $tag -replace '^v', ''
31+
if ($version -notmatch '^\d+\.\d+') {
32+
$version = "0.0.0-$version"
33+
}
34+
Write-Host "Version from tag: $version"
35+
echo "version=$version" >> $env:GITHUB_OUTPUT
36+
} else {
37+
Write-Host "No tag found, using default version"
38+
echo "version=1.0.0" >> $env:GITHUB_OUTPUT
39+
}
40+
shell: pwsh
41+
42+
- name: Restore dependencies
43+
run: dotnet restore src\IoTPowerShellAgent\IoTPowerShellAgent.csproj
44+
45+
- name: Build
46+
run: dotnet build src\IoTPowerShellAgent\IoTPowerShellAgent.csproj --configuration Release /p:Version=${{ steps.version.outputs.version }}

‎.gitignore‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Build results
2+
[Dd]ebug/
3+
[Dd]ebugPublic/
4+
[Rr]elease/
5+
[Rr]eleases/
6+
x64/
7+
x86/
8+
[Ww][Ii][Nn]32/
9+
[Aa][Rr][Mm]/
10+
[Aa][Rr][Mm]64/
11+
bld/
12+
[Bb]in/
13+
[Oo]bj/
14+
[Ll]og/
15+
[Ll]ogs/
16+
17+
# Visual Studio cache/options directory
18+
.vs/
19+
20+
# User-specific files
21+
*.rsuser
22+
*.suo
23+
*.user
24+
*.userosscache
25+
*.sln.docstates
26+
27+
# NuGet Packages
28+
*.nupkg
29+
*.snupkg
30+
**/packages/*
31+
!**/packages/build/
32+
33+
# Local settings
34+
config/appsettings.Development.json
35+
config/appsettings.Local.json
36+
AGENTS.md
37+
.claude/agents/repo_expert.md
38+
39+
# Test results
40+
*.trx
41+
*.coverage
42+
*.coveragexml
43+
TestResults/
44+
45+
# Pester test results
46+
PesterResults.xml
47+
backend/README.md
48+
backend/main.bicepparam
49+
.gitignore
50+
backend/New-DpsEnrollment.ps1
51+
backend/main.bicep

‎.vscode/launch.json‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
// Use IntelliSense to find out which attributes exist for C# debugging
6+
// Use hover for the description of the existing attributes
7+
// For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md
8+
"name": ".NET Core Launch (console)",
9+
"type": "coreclr",
10+
"request": "launch",
11+
"preLaunchTask": "build",
12+
// If you have changed target frameworks, make sure to update the program path.
13+
"program": "${workspaceFolder}/src/IoTPowerShellAgent/bin/Debug/net8.0-windows/IoTPowerShellAgent.dll",
14+
"args": [],
15+
"cwd": "${workspaceFolder}/src/IoTPowerShellAgent",
16+
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
17+
"console": "internalConsole",
18+
"stopAtEntry": false
19+
},
20+
{
21+
"name": ".NET Core Attach",
22+
"type": "coreclr",
23+
"request": "attach"
24+
}
25+
]
26+
}

‎.vscode/tasks.json‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "build",
6+
"command": "dotnet",
7+
"type": "process",
8+
"args": [
9+
"build",
10+
"${workspaceFolder}/src/IoTPowerShellAgent/IoTPowerShellAgent.csproj",
11+
"/property:GenerateFullPaths=true",
12+
"/consoleloggerparameters:NoSummary;ForceNoAlign"
13+
],
14+
"problemMatcher": "$msCompile"
15+
},
16+
{
17+
"label": "publish",
18+
"command": "dotnet",
19+
"type": "process",
20+
"args": [
21+
"publish",
22+
"${workspaceFolder}/src/IoTPowerShellAgent/IoTPowerShellAgent.csproj",
23+
"/property:GenerateFullPaths=true",
24+
"/consoleloggerparameters:NoSummary;ForceNoAlign"
25+
],
26+
"problemMatcher": "$msCompile"
27+
},
28+
{
29+
"label": "watch",
30+
"command": "dotnet",
31+
"type": "process",
32+
"args": [
33+
"watch",
34+
"run",
35+
"--project",
36+
"${workspaceFolder}/src/IoTPowerShellAgent/IoTPowerShellAgent.csproj"
37+
],
38+
"problemMatcher": "$msCompile"
39+
}
40+
]
41+
}

‎CONTRIBUTING.md‎

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Contributing to IoTPowerShellAgent
2+
3+
Thank you for your interest in contributing to IoTPowerShellAgent! This document provides guidelines and instructions for contributing.
4+
5+
## Code of Conduct
6+
7+
- Be respectful and inclusive
8+
- Welcome newcomers and help them learn
9+
- Focus on constructive feedback
10+
- Respect different viewpoints and experiences
11+
12+
## Getting Started
13+
14+
1. Fork the repository
15+
2. Clone your fork: `git clone https://github.com/Calvindd2f/IoTPowerShellAgent.git`
16+
3. Create a branch: `git checkout -b feature/your-feature-name`
17+
4. Make your changes
18+
5. Test your changes thoroughly
19+
6. Commit your changes: `git commit -m "Add feature: description"`
20+
7. Push to your fork: `git push origin feature/your-feature-name`
21+
8. Open a Pull Request
22+
23+
## Development Setup
24+
25+
### Prerequisites
26+
27+
- .NET 8.0 SDK or later
28+
- Windows 10/11 or Windows Server 2016+
29+
- PowerShell 5.1 or later
30+
- Visual Studio 2022 or VS Code (recommended)
31+
32+
### Building
33+
34+
```bash
35+
dotnet restore
36+
dotnet build
37+
```
38+
39+
### Running Tests
40+
41+
```bash
42+
dotnet test
43+
```
44+
45+
## Coding Standards
46+
47+
### C# Code Style
48+
49+
- Use meaningful variable and method names
50+
- Follow C# naming conventions (PascalCase for public members, camelCase for private)
51+
- Use `using var` for disposable objects where appropriate
52+
- Add XML documentation comments for public APIs
53+
- Keep methods focused and single-purpose
54+
55+
### PowerShell Code Style
56+
57+
- Use approved verbs (Get-, Set-, New-, etc.)
58+
- Follow PowerShell naming conventions
59+
- Include help comments for functions
60+
61+
### Error Handling
62+
63+
- Always handle exceptions appropriately
64+
- Provide meaningful error messages
65+
- Log errors with appropriate severity levels
66+
- Use structured error details for PowerShell errors
67+
68+
## Testing
69+
70+
- Write unit tests for new features
71+
- Ensure existing tests pass
72+
- Test edge cases and error conditions
73+
- For PowerShell executor tests, consider using Pester integration
74+
75+
### Running Pester Tests
76+
77+
If you add Pester tests, run them with:
78+
79+
```powershell
80+
Invoke-Pester -Path .\src\IoTPowerShellAgent.Tests.Pester\PowerShell\
81+
```
82+
83+
## Pull Request Process
84+
85+
1. Update documentation if needed
86+
2. Ensure all tests pass
87+
3. Update CHANGELOG.md if applicable
88+
4. Ensure your code follows the coding standards
89+
5. Request review from maintainers
90+
6. Address any feedback
91+
92+
## Commit Messages
93+
94+
Use clear, descriptive commit messages:
95+
96+
- Use present tense ("Add feature" not "Added feature")
97+
- First line should be a summary (50 chars or less)
98+
- Include more details in the body if needed
99+
- Reference issues/PRs if applicable
100+
101+
Examples:
102+
103+
```
104+
Add async execution with cancellation token support
105+
106+
Implements ExecutePowerShellAsync method with SemaphoreSlim
107+
throttling to prevent blocking IoT Hub listener thread.
108+
```
109+
110+
## Versioning
111+
112+
This project uses [Semantic Versioning](https://semver.org/):
113+
114+
- MAJOR version for incompatible API changes
115+
- MINOR version for backwards-compatible functionality
116+
- PATCH version for backwards-compatible bug fixes
117+
118+
## Questions?
119+
120+
If you have questions, please:
121+
122+
- Open an issue for discussion
123+
- Check existing issues and discussions
124+
- Reach out to maintainers
125+
126+
Thank you for contributing!

‎Directory.Build.props‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project>
2+
<PropertyGroup>
3+
<!-- Semantic versioning: version will be set from Git tags -->
4+
<!-- Format: v1.2.3 or 1.2.3 or 1.2.3-preview -->
5+
<Version Condition="'$(Version)' == ''">1.0.0</Version>
6+
7+
<!-- Strip any pre-release suffix for AssemblyVersion/FileVersion (they only accept numeric major.minor.build.revision) -->
8+
<_VersionPrefix>$([System.Text.RegularExpressions.Regex]::Match($(Version), '^\d+\.\d+\.\d+(\.\d+)?'))</_VersionPrefix>
9+
<_VersionPrefix Condition="'$(_VersionPrefix)' == ''">1.0.0</_VersionPrefix>
10+
11+
<AssemblyVersion Condition="'$(AssemblyVersion)' == ''">$(_VersionPrefix)</AssemblyVersion>
12+
<FileVersion Condition="'$(FileVersion)' == ''">$(_VersionPrefix)</FileVersion>
13+
<InformationalVersion Condition="'$(InformationalVersion)' == ''">$(Version)</InformationalVersion>
14+
</PropertyGroup>
15+
</Project>
16+

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Calvindd2f Contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)