Add GitHub Actions CI workflow using dotnet commands directly - #1
Conversation
Agent-Logs-Url: https://github.com/yangxiaobai945/VisualKeyBoard/sessions/5fe14408-72a0-4b54-9e15-916956d90648 Co-authored-by: yangxiaobai945 <120302694+yangxiaobai945@users.noreply.github.com>
|
@copilot 合并这个 pr |
合并 PR 需要仓库维护者手动操作,我无法直接执行合并。请在 GitHub 页面上点击 "Merge pull request" 按钮完成合并。 |
There was a problem hiding this comment.
Pull request overview
Adds a first GitHub Actions CI workflow to build the WinForms/.NET solution on Windows runners using dotnet CLI commands (instead of invoking build.ps1), providing basic PR/push validation on main.
Changes:
- Introduces a new
Buildworkflow running onwindows-latest. - Restores and builds the solution in
Releaseusingdotnet restore+dotnet build --no-restore. - Scopes GITHUB_TOKEN permissions to
contents: read.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - name: Restore dependencies | ||
| run: dotnet restore VisualKeyBoard.sln | ||
|
|
||
| - name: Build | ||
| run: dotnet build VisualKeyBoard.sln -c Release --no-restore |
There was a problem hiding this comment.
The workflow builds VisualKeyBoard.sln, but the repo’s documented/automated build path prefers VisualKeyBoard.slnx when present (see build.ps1 and README). This can cause CI to build a different solution than local builds and will break if the .sln is ever removed or becomes out of sync. Consider using the .slnx file (or adding a small step to select .slnx when it exists, falling back to .sln), matching build.ps1’s behavior.
| - name: Restore dependencies | |
| run: dotnet restore VisualKeyBoard.sln | |
| - name: Build | |
| run: dotnet build VisualKeyBoard.sln -c Release --no-restore | |
| - name: Select solution file | |
| id: select-solution | |
| shell: pwsh | |
| run: | | |
| if (Test-Path 'VisualKeyBoard.slnx') { | |
| "solution=VisualKeyBoard.slnx" >> $env:GITHUB_OUTPUT | |
| } else { | |
| "solution=VisualKeyBoard.sln" >> $env:GITHUB_OUTPUT | |
| } | |
| - name: Restore dependencies | |
| run: dotnet restore ${{ steps.select-solution.outputs.solution }} | |
| - name: Build | |
| run: dotnet build ${{ steps.select-solution.outputs.solution }} -c Release --no-restore |
The repo had no CI workflow. The issue requests building via
dotnetcommands rather than invokingbuild.ps1.Changes
.github/workflows/build.yml— new CI workflow that:windows-latest(required fornet8.0-windows/ WinForms target)maindotnetdirectly, skippingbuild.ps1:permissions: contents: readfor least-privilege token scoping