Attempt to fix publishing in VS #1680
Workflow file for this run
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 of the workflow | |
| name: CI | |
| # Controls when the action will run. Triggers the workflow on push or pull request events | |
| on: | |
| push: | |
| branches: [ master, release/*, feature/* ] | |
| paths-ignore: | |
| - '**/*.md' | |
| pull_request: | |
| branches: [ master ] | |
| workflow_dispatch: | |
| permissions: | |
| id-token: write # required for GitHub OIDC | |
| # A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
| jobs: | |
| # Run the build first | |
| build: | |
| # The type of runner that the job will run on | |
| runs-on: ubuntu-latest | |
| # Steps represent a sequence of tasks that will be executed as part of the job | |
| steps: | |
| # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 # avoid shallow clone so nbgv can do its work. | |
| # Install .NET SDK's for 8.0, 9.0 and 10.0 | |
| - name: Setup dotnet 10.0 | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '10.0.x' | |
| - name: Setup dotnet 9.0 | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '9.0.x' | |
| - name: Setup dotnet 8.0 | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '8.0.x' | |
| # Install Nerdbank.GitVersioning | |
| - name: install nbgv | |
| run: dotnet tool install --tool-path . nbgv | |
| # Set version | |
| - name: set version | |
| run: ./nbgv cloud -p ./src/MSBuild.Sdk.SqlProj/ --all-vars | |
| # Build command line tool | |
| - name: dotnet build DacpacTool | |
| run: dotnet build ./src/DacpacTool/DacpacTool.csproj -c Release | |
| # Run tests for command line tool | |
| - name: dotnet test | |
| run: dotnet test ./test/DacpacTool.Tests/DacpacTool.Tests.csproj -c Release | |
| # Run build for SDK package | |
| - name: dotnet build SDK | |
| run: dotnet build ./src/MSBuild.Sdk.SqlProj/MSBuild.Sdk.SqlProj.csproj -c Release | |
| # Ensure that test projects build | |
| - name: dotnet build TestProject | |
| run: dotnet build ./test/TestProject/TestProject.csproj -c Release | |
| - name: dotnet build TestProjectWithAnalyzers | |
| run: dotnet build ./test/TestProjectWithAnalyzers/TestProjectWithAnalyzers.csproj -c Release | |
| - name: dotnet build TestProjectWithGenerateScriptAndTargetDatabaseName | |
| run: dotnet build ./test/TestProjectWithGenerateScriptAndTargetDatabaseName/TestProjectWithGenerateScriptAndTargetDatabaseName.csproj -c Release | |
| # Package SDK | |
| - name: dotnet pack SDK | |
| run: dotnet pack -c Release src/MSBuild.Sdk.SqlProj/MSBuild.Sdk.SqlProj.csproj | |
| # Upload SDK package | |
| - name: upload SDK | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: sdk-package | |
| path: ./src/MSBuild.Sdk.SqlProj/bin/Release/ | |
| # Package TestProject | |
| - name: dotnet pack TestProject | |
| run: dotnet pack -c Release ./test/TestProject/TestProject.csproj | |
| # Upload TestProject package | |
| - name: upload TestProject | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: test-package | |
| path: ./test/TestProject/bin/Release/ | |
| # Replace tokens | |
| - uses: cschleiden/replace-tokens@v1 | |
| name: replace tokens | |
| with: | |
| files: 'src/MSBuild.Sdk.SqlProj.Templates/templates/sqlproj/sqlproj.csproj' | |
| # Package templates | |
| - name: dotnet pack templates | |
| run: dotnet pack -c Release src/MSBuild.Sdk.SqlProj.Templates/MSBuild.Sdk.SqlProj.Templates.csproj | |
| # Upload templates package | |
| - name: upload templates | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: template-package | |
| path: ./src/MSBuild.Sdk.SqlProj.Templates/bin/Release/ | |
| # Run tests in parallel | |
| test: | |
| runs-on: ${{ matrix.os }} | |
| needs: build | |
| strategy: | |
| matrix: | |
| os: [ "ubuntu-22.04", "macos-14", "windows-2022" ] | |
| dotnet: [ '8.0.x', '9.0.x', '10.0.x' ] | |
| fail-fast: false | |
| steps: | |
| # Fetch sources | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 # avoid shallow clone so nbgv can do its work. | |
| # Setup .NET SDK | |
| - uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: ${{ matrix.dotnet }} | |
| # Install Nerdbank.GitVersioning | |
| - name: install nbgv | |
| run: dotnet tool install --tool-path . nbgv | |
| # Set version | |
| - name: set version | |
| run: ./nbgv cloud -p ./src/MSBuild.Sdk.SqlProj/ --all-vars | |
| id: nbgv | |
| # Replace tokens | |
| - uses: cschleiden/replace-tokens@v1 | |
| name: replace tokens | |
| with: | |
| files: 'test/TestProjectWithSDKRef/TestProjectWithSDKRef.csproj' | |
| # Download artifact | |
| - name: download-artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: sdk-package | |
| path: test/TestProjectWithSDKRef/nuget-packages | |
| # Download artifact | |
| - name: download-artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: test-package | |
| path: test/TestProjectWithSDKRef/nuget-packages | |
| # Build the project using exact version number | |
| - name: build project (exact version / MSBuild resolution) | |
| run: dotnet build ./test/TestProjectWithSDKRef/TestProjectWithSDKRef.csproj /bl /p:DependencyVersion="$Env:NBGV_NuGetPackageVersion" /warnaserror:SQL71502 | |
| shell: pwsh | |
| # Build the project using fallback method of resolving version via path | |
| - name: build project (exact version / path resolution) | |
| run: dotnet build ./test/TestProjectWithSDKRef/TestProjectWithSDKRef.csproj /bl /p:DependencyVersion="$Env:NBGV_NuGetPackageVersion" /p:PkgTestProject="" /warnaserror:SQL71502 | |
| shell: pwsh | |
| # Upload binary log | |
| - name: upload | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: binary-log-${{ matrix.os }}-${{ matrix.dotnet }}-exact-version | |
| path: ./msbuild.binlog | |
| # Build the project using single wildcard (i.e. 1.x.x-*) | |
| - name: build project (single floating version) | |
| run: dotnet build ./test/TestProjectWithSDKRef/TestProjectWithSDKRef.csproj /bl /p:DependencyVersion="${Env:NBGV_SimpleVersion}-*" /warnaserror:SQL71502 | |
| shell: pwsh | |
| # Build the project using double wildcard (i.e. 1.*-*) | |
| - name: build project (double floating version / dotnet 3) | |
| run: dotnet build ./test/TestProjectWithSDKRef/TestProjectWithSDKRef.csproj /bl /p:DependencyVersion="2.*-*" /warnaserror:SQL71502 | |
| shell: pwsh | |
| # Upload dacpac | |
| - name: upload | |
| if: ${{ matrix.os == 'ubuntu-22.04' && matrix.dotnet == '8.0.x' }} | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: dacpac-package | |
| path: ./test/TestProjectWithSDKRef/bin/Debug/net8.0/ | |
| # Upload binary log | |
| - name: upload | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: binary-log-${{ matrix.os }}-${{ matrix.dotnet }}-floating-version | |
| path: ./msbuild.binlog | |
| # Attempt to deploy the resulting dacpac's to a SQL Server instance running in a container using SqlPackage.exe | |
| deploy-sqlpackage: | |
| runs-on: ubuntu-22.04 | |
| needs: test | |
| steps: | |
| # Start SQL Server container | |
| - name: Start SQL Server | |
| run: | | |
| docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=${{ secrets.SQL_SA_PASSWORD }}" \ | |
| -p 1433:1433 --name sqlserver -d \ | |
| mcr.microsoft.com/mssql/server:2022-latest | |
| # Wait for SQL Server to be ready | |
| - name: Wait for SQL Server | |
| run: | | |
| echo "Waiting for SQL Server to start..." | |
| sql_ready=false | |
| for i in {1..30}; do | |
| if docker exec sqlserver /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P "${{ secrets.SQL_SA_PASSWORD }}" -Q "SELECT 1" > /dev/null 2>&1; then | |
| echo "SQL Server is ready!" | |
| sql_ready=true | |
| break | |
| fi | |
| echo "Attempt $i: SQL Server not ready, waiting..." | |
| sleep 10 | |
| done | |
| if [ "$sql_ready" != true ]; then | |
| echo "SQL Server did not become ready after 30 attempts. Failing job." >&2 | |
| exit 1 | |
| fi | |
| # Download artifacts | |
| - name: download-artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: dacpac-package | |
| path: ~/dacpac-package | |
| # Setup .NET SDK | |
| - uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '8.0.x' | |
| # Install Microsoft.SqlPackage | |
| - name: install microsoft.sqlpackage | |
| run: dotnet tool install --tool-path . microsoft.sqlpackage | |
| # Run sqlpackage | |
| - name: sqlpackage publish | |
| run: > | |
| sqlpackage | |
| /Action:Publish | |
| /SourceFile:$HOME/dacpac-package/TestProjectWithSDKRef.dacpac | |
| /Properties:IncludeCompositeObjects=True | |
| /TargetServerName:localhost | |
| /TargetUser:sa | |
| /TargetPassword:${{ secrets.SQL_SA_PASSWORD }} | |
| /TargetDatabaseName:TestProjectWithSDKRef | |
| /TargetEncryptConnection:False | |
| # Verify deployment | |
| - name: verify-deployment | |
| run: | | |
| echo "Verifying deployment..." | |
| if docker exec sqlserver /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P "${{ secrets.SQL_SA_PASSWORD }}" -b -d TestProjectWithSDKRef -Q "SELECT 1 FROM dbo.TestTable;"; then | |
| echo "Deployment succeeded!" | |
| else | |
| echo "Deployment failed!" >&2 | |
| exit 1 | |
| fi | |
| # Dump logs of the container if something failed | |
| - name: Dump docker logs on failure | |
| if: failure() | |
| uses: jwalton/gh-docker-logs@v2 | |
| # Attempt to deploy a project to a SQL Server instance running in a container using dotnet publish | |
| deploy-publish: | |
| runs-on: ubuntu-22.04 | |
| needs: test | |
| steps: | |
| # Start SQL Server container | |
| - name: Start SQL Server | |
| run: | | |
| docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=${{ secrets.SQL_SA_PASSWORD }}" \ | |
| -p 1433:1433 --name sqlserver -d \ | |
| mcr.microsoft.com/mssql/server:2022-latest | |
| # Wait for SQL Server to be ready | |
| - name: Wait for SQL Server | |
| run: | | |
| echo "Waiting for SQL Server to start..." | |
| sql_ready=false | |
| for i in {1..30}; do | |
| if docker exec sqlserver /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P "${{ secrets.SQL_SA_PASSWORD }}" -Q "SELECT 1" > /dev/null 2>&1; then | |
| echo "SQL Server is ready!" | |
| sql_ready=true | |
| break | |
| fi | |
| echo "Attempt $i: SQL Server not ready, waiting..." | |
| sleep 10 | |
| done | |
| if [ "$sql_ready" != "true" ]; then | |
| echo "SQL Server did not become ready after 30 attempts." >&2 | |
| exit 1 | |
| fi | |
| # Fetch sources | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 # avoid shallow clone so nbgv can do its work. | |
| # Download SDK | |
| - name: download-artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: sdk-package | |
| path: test/TestProjectWithSDKRef/nuget-packages | |
| # Download test package | |
| - name: download-artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: test-package | |
| path: test/TestProjectWithSDKRef/nuget-packages | |
| # Setup .NET SDK | |
| - uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '8.0.x' | |
| # Install Nerdbank.GitVersioning | |
| - name: install nbgv | |
| run: dotnet tool install --tool-path . nbgv | |
| # Set version | |
| - name: set version | |
| run: ./nbgv cloud -p ./src/MSBuild.Sdk.SqlProj/ --all-vars | |
| id: nbgv | |
| # Replace tokens | |
| - uses: cschleiden/replace-tokens@v1 | |
| name: replace tokens | |
| with: | |
| files: 'test/TestProjectWithSDKRef/TestProjectWithSDKRef.csproj' | |
| env: | |
| DependencyVersion: '2.*-*' | |
| # Publish the project | |
| - name: publish project | |
| run: dotnet publish ./test/TestProjectWithSDKRef/TestProjectWithSDKRef.csproj /t:PublishDatabase /p:TargetUser=sa /p:TargetPassword=${{ secrets.SQL_SA_PASSWORD }} /bl /p:DependencyVersion="2.*-*" /warnaserror:SQL71502 | |
| # Verify deployment | |
| - name: verify-deployment | |
| run: | | |
| echo "Verifying deployment..." | |
| if docker exec sqlserver /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P "${{ secrets.SQL_SA_PASSWORD }}" -b -d TestProjectWithSDKRef -Q "SELECT 1 FROM dbo.TestTable;"; then | |
| echo "Deployment succeeded!" | |
| else | |
| echo "Deployment failed!" >&2 | |
| exit 1 | |
| fi | |
| # Upload binary log | |
| - name: upload | |
| uses: actions/upload-artifact@v6 | |
| if: failure() | |
| with: | |
| name: binary-log-publish | |
| path: ./msbuild.binlog | |
| # Dump logs of the container if something failed | |
| - name: Dump docker logs on failure | |
| if: failure() | |
| uses: jwalton/gh-docker-logs@v2 | |
| # Attempt to publish the project as a container image and use that to deploy the resulting dacpac's to a SQL Server instance running in a container | |
| deploy-container: | |
| runs-on: ubuntu-22.04 | |
| needs: test | |
| steps: | |
| # Start SQL Server container | |
| - name: Start SQL Server | |
| run: | | |
| docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=${{ secrets.SQL_SA_PASSWORD }}" \ | |
| -p 1433:1433 --name sqlserver -d \ | |
| mcr.microsoft.com/mssql/server:2022-latest | |
| # Wait for SQL Server to be ready | |
| - name: Wait for SQL Server | |
| run: | | |
| echo "Waiting for SQL Server to start..." | |
| sql_ready=false | |
| for i in {1..30}; do | |
| if docker exec sqlserver /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P "${{ secrets.SQL_SA_PASSWORD }}" -Q "SELECT 1" > /dev/null 2>&1; then | |
| echo "SQL Server is ready!" | |
| sql_ready=true | |
| break | |
| fi | |
| echo "Attempt $i: SQL Server not ready, waiting..." | |
| sleep 10 | |
| done | |
| if [ "$sql_ready" != true ]; then | |
| echo "SQL Server did not become ready after 30 attempts. Failing job." >&2 | |
| exit 1 | |
| fi | |
| # Setup .NET SDK | |
| - uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '8.0.x' | |
| # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 # avoid shallow clone so nbgv can do its work. | |
| # Download SDK | |
| - name: download-artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: sdk-package | |
| path: test/TestProjectWithSDKRef/nuget-packages | |
| # Download test package | |
| - name: download-artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: test-package | |
| path: test/TestProjectWithSDKRef/nuget-packages | |
| # Setup .NET SDK | |
| - uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '8.0.x' | |
| # Install Nerdbank.GitVersioning | |
| - name: install nbgv | |
| run: dotnet tool install --tool-path . nbgv | |
| # Set version | |
| - name: set version | |
| run: ./nbgv cloud -p ./src/MSBuild.Sdk.SqlProj/ --all-vars | |
| id: nbgv | |
| # Replace tokens | |
| - uses: cschleiden/replace-tokens@v1 | |
| name: replace tokens | |
| with: | |
| files: 'test/TestProjectWithSDKRef/TestProjectWithSDKRef.csproj' | |
| env: | |
| DependencyVersion: '2.*-*' | |
| # Publish the project as a container image | |
| - name: publish-container | |
| run: > | |
| dotnet | |
| publish | |
| ./test/TestProjectWithSDKRef/TestProjectWithSDKRef.csproj | |
| /t:PublishContainer | |
| /bl | |
| /p:DependencyVersion="2.*-*" | |
| # Run the container to publish the dacpac | |
| - name: container publish | |
| run: > | |
| docker | |
| run | |
| --network host | |
| testprojectwithsdkref:latest | |
| /Properties:IncludeCompositeObjects=True | |
| /TargetServerName:localhost | |
| /TargetUser:sa | |
| /TargetPassword:${{ secrets.SQL_SA_PASSWORD }} | |
| /TargetDatabaseName:TestProjectWithSDKRef | |
| /TargetEncryptConnection:False | |
| # Verify deployment | |
| - name: verify-deployment | |
| run: | | |
| echo "Verifying deployment..." | |
| if docker exec sqlserver /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P "${{ secrets.SQL_SA_PASSWORD }}" -b -d TestProjectWithSDKRef -Q "SELECT 1 FROM dbo.TestTable;"; then | |
| echo "Deployment succeeded!" | |
| else | |
| echo "Deployment failed!" >&2 | |
| exit 1 | |
| fi | |
| # Dump logs of the container if something failed | |
| - name: Dump docker logs on failure | |
| if: failure() | |
| uses: jwalton/gh-docker-logs@v2 | |
| # Upload binary log | |
| - name: upload | |
| uses: actions/upload-artifact@v6 | |
| if: failure() | |
| with: | |
| name: binary-log-publish | |
| path: ./msbuild.binlog | |
| # Publish the NuGet package to NuGet.org when building master branch | |
| publish: | |
| permissions: | |
| id-token: write # enable GitHub OIDC token issuance for this job | |
| runs-on: ubuntu-22.04 | |
| if: startsWith(github.ref, 'refs/heads/release/') | |
| needs: | |
| - deploy-sqlpackage | |
| - deploy-publish | |
| steps: | |
| # Setup .NET SDK | |
| - uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '8.0.x' | |
| # Download SDK package | |
| - name: download-sdk-package | |
| uses: actions/download-artifact@v7 | |
| id: download-sdk-package | |
| with: | |
| name: sdk-package | |
| path: ~/nuget-packages | |
| # Download Templates package | |
| - name: download-template-package | |
| uses: actions/download-artifact@v7 | |
| id: download-template-package | |
| with: | |
| name: template-package | |
| path: ~/nuget-packages | |
| - name: Display structure of downloaded files | |
| run: ls -R | |
| working-directory: ${{steps.download-sdk-package.outputs.download-path}} | |
| # Get a short-lived NuGet API key | |
| - name: NuGet login (OIDC → temp API key) | |
| uses: NuGet/login@v1 | |
| id: login | |
| with: | |
| user: ${{ secrets.NUGET_USER }} | |
| # Push | |
| - name: dotnet nuget push | |
| run: dotnet nuget push 'MSBuild.Sdk.SqlProj*.nupkg' --api-key ${{steps.login.outputs.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate | |
| working-directory: ${{steps.download-sdk-package.outputs.download-path}} |