Search code examples
github-actionsblazor-webassembly.net-6.0

Add .Net 6 telerik nuget feed to Github action


I have a Blazor wasm project in .Net 6 and I am trying to use Github action for CI/CD. I am getting following error, when running github action

Run dotnet restore Client/Client.csproj --runtime any
  dotnet restore Client/Client.csproj --runtime any
  shell: /usr/bin/bash -e {0}
  env:
    DOTNET_ROOT: /home/runner/.dotnet
    TELERIK_USERNAME: ***
    TELERIK_PASSWORD: ***
  Determining projects to restore...
/home/runner/work/fleetBASE/fleetBASE/Client/Client.csproj : error NU1101: Unable to find package Telerik.UI.for.Blazor. No packages exist with this id in source(s): nuget.org
  Failed to restore /home/runner/work/fleetBASE/fleetBASE/Client/Client.csproj (in 8.94 sec).
Error: Process completed with exit code 1.

FYI, I tried sample Blazor wasm project in .Net 6 without telerik, and it worked perfectly. My github action looks like this:

name: Azure Static Web Apps CI/CD

on:
  push:
    branches:
      - Poc_ADB2C
  pull_request:
    types: [opened, synchronize, reopened, closed]
    branches:
      - Poc_ADB2C

jobs:
  build_and_deploy_job:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
    runs-on: ubuntu-latest
    name: Build and Deploy Job
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true
      - name: Setup .NET Core SDK
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: '6.0.x'
      - name: Restore NuGet Packages
        run: dotnet restore Client/Client.csproj --runtime any
        env:
            TELERIK_USERNAME: ${{ secrets.MyTelerikAccountUsername }}
            TELERIK_PASSWORD: ${{ secrets.MyTelerikAccountPassword }}

      - name: Build And Deploy
        env:
            TELERIK_USERNAME: ${{ secrets.MyTelerikAccountUsername }}
            TELERIK_PASSWORD: ${{ secrets.MyTelerikAccountPassword }}
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_WONDERFUL_HILL_0F2E3E10F }}
          repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
          action: "upload"
          ###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
          # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
          app_location: "Client" # App source code path
          output_location: "wwwroot" # Built app content directory - optional
          ###### End of Repository/Build Configurations ######

  close_pull_request_job:
    if: github.event_name == 'pull_request' && github.event.action == 'closed'
    runs-on: ubuntu-latest
    name: Close Pull Request Job
    steps:
      - name: Close Pull Request
        id: closepullrequest
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_WONDERFUL_HILL_0F2E3E10F }}
          action: "close"

I couldn't find option to add telerik nuget feed in GitHub action. What am I missing here?


Solution

  • Finally I figured it out, I had to add telerik feed through NuGet.Config and pass it in dotnet restore command in the workflow. Also I had to add telerik credentials in Nuget.Config in ClearTextPassword.

    Sample Nuget.Config:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
         <packageSources>
           <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
           <add key="telerik.com" value="https://nuget.telerik.com/nuget" />
          </packageSources>
          <packageSourceCredentials>
            <telerik.com>
              <add key="Username" value="XXXXXXX" />
              <add key="ClearTextPassword" value="XXXXXXX" />
            </telerik.com>
          </packageSourceCredentials>   
    </configuration>
    

    Sample github action workflow:

    name: Azure Static Web Apps CI/CD
    
    on:
      push:
        branches:
          - dev
      pull_request:
        types: [opened, synchronize, reopened, closed]
        branches:
          - dev
    
    jobs:
      build_and_deploy_job:
        if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
        runs-on: ubuntu-latest
        name: Build and Deploy Job
        steps:
          - uses: actions/checkout@v2
            with:
              submodules: true
          - name: Setup .NET Core SDK
            uses: actions/setup-dotnet@v1
            with:
              dotnet-version: '6.0.x'
          - name: Restore NuGet Packages
            run: dotnet restore Client/Client.csproj --configfile Client/NuGet.Config --runtime any
          - name: Build And Deploy
            id: builddeploy
            uses: Azure/static-web-apps-deploy@v1
            with:
              azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_WONDERFUL_HILL_0F2E3E10F }}
              repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
              action: "upload"
          ###### Repository/Build Configurations - These values can be configured to match your app requirements. ######          
              app_location: "Client" # App source code path
          #api_location: "Api" # Api source code path - optional
              output_location: "wwwroot" # Built app content directory - optional
          ###### End of Repository/Build Configurations ######
    
      close_pull_request_job:
        if: github.event_name == 'pull_request' && github.event.action == 'closed'
        runs-on: ubuntu-latest
        name: Close Pull Request Job
        steps:
          - name: Close Pull Request
            id: closepullrequest
            uses: Azure/static-web-apps-deploy@v1
            with:
              azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_WONDERFUL_HILL_0F2E3E10F }}
              action: "close"
    

    Note: Sometimes Github action fails for unknown reason, so just re run the workflow.