Refactor .NET Core Desktop workflow configuration #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: .NET Core Desktop Build | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| configuration: [Debug, Release] | |
| runs-on: windows-latest | |
| env: | |
| Solution_Name: ShowWrite.sln # 替换为你的解决方案名称 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # 安装 .NET Core SDK | |
| - name: Install .NET Core | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 8.0.x | |
| # 添加 MSBuild 到 PATH | |
| - name: Setup MSBuild.exe | |
| uses: microsoft/setup-msbuild@v2 | |
| # 还原 NuGet 包 | |
| - name: Restore NuGet packages | |
| run: dotnet restore $env:Solution_Name | |
| # 构建解决方案 | |
| - name: Build solution | |
| run: msbuild $env:Solution_Name /p:Configuration=${{ matrix.configuration }} /p:Platform="Any CPU" /t:Build | |
| # 可选:执行单元测试(如果有测试项目) | |
| # - name: Run unit tests | |
| # run: dotnet test --no-build --verbosity normal |