Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
330 stars 56 forks source link

Not able to resolve packages from private nuget #954

Open jkears opened 2 years ago

jkears commented 2 years ago

We have deployed a Blazor WASM project into Azure Static Apps and the WASM project references several packages in our private Nuget.

When running the GitHub action as generated by Azure Static Web Apps, we get an error at the Build and Deploy step when restoring the Blazor WASM project as it is unable to find the package(s) that is/are in the private nuget service.

/github/workspace/NextWare.Portal.Wasm/NextWare.Portal.Wasm.csproj : error NU1101: Unable to find package NextWare.CoreServices.Meta.SharedModels. No packages exist with this id in source(s): nuget.org

We have Nuget.Config within the WASM project folder as well as the root folder for the solution.

Here is our workflow as generated by Azure Static Web Apps...

name: Azure Static Web Apps CI/CD

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

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: Add Private Nuget source
        run: dotnet nuget add source  SourceToNugetService --name NameOfNugetService
      - 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_JOLLY_SKY_0E29A4D0F }}
          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: "path/to/blazorWasm" # App source code path
          app_location: "NextWare.Portal.Wasm"
          api_location: "" # Api source code path - optional
          #output_location: "wwwroot" # Built app content directory - optional
          skip_api_build: true
          ###### 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_JOLLY_SKY_0E29A4D0F }}
          action: "close"
vivekjilla commented 2 years ago

@jkears In the "Add Private Nuget source" step, as the source is private, you might have to provide some credentials as well to successfully add the source using dotnet nuget add source command? Here's an example for source that needs authentication https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-add-source#examples

Please check if it helps.