Building static web apps from devops is looking good and easy to use. However we have run into a problem where we have some npm packages from our private feed, this is defined in our .npmrc file, however it appears to have problems installing packages.
.npmrc
registry=https://pkgs.dev.azure.com/xxx/_packaging/yyy/npm/registry/
always-auth=true;
For a normal pipeline build (using npm) we can define the feed in npm parameters:
- task: Npm@1
name: NpmInstall
inputs:
command: 'install'
workingDir: 'Clients/React'
customRegistry: 'useFeed'
customFeed: 'xxx'
Is it possible to specify a customFeed in the same way using the SPA pipeline task?
The pipeline output is:
Running 'npm install --unsafe-perm --production'...
npm ERR! code E401
npm ERR! Unable to authenticate, need: Bearer authorization_uri=https://login.windows.net/xxxx, Basic realm="https://pkgsprodcus1.pkgs.visualstudio.com/", TFS-Federated
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-03-24T18_55_50_798Z-debug.log
@krisnuttall To get around this for now, build your app in separate steps and use the AzureStaticWebApp task to publish only. To do this, set the app_location to the build output location from the previous step (build, dist, etc). Leave output_location empty.
Thanks @anthonychu the workaround works well:
- task: npmBuild
.....
- task: AzureStaticWebApp@0
inputs:
app_location: 'Clients/React/build'
env:
azure_static_web_apps_api_token: xxx
We have a similar or same issue for a Blazor WebAssembly that uses a private Azure DevOps artifact.
- task: AzureStaticWebApp@0
inputs:
app_location: "scream4meV2.AdminTool"
api_location: ""
output_location: "wwwroot"
env:
azure_static_web_apps_api_token: $(deployment_token)
gives the following error when run:
2021-04-04T20:36:17.8011340Z [37m Determining projects to restore...[0m
2021-04-04T20:36:18.5354965Z [37m/tmp/oryx/platforms/dotnet/5.0.103/sdk/5.0.103/NuGet.targets(131,5): error : Unable to load the service index for source https://pkgs.dev.azure.com/scream4me/_packaging/scream4meV2.Shared/nuget/v3/index.json. [/working_dir/scream4meV2.AdminTool/scream4meV2.AdminTool.csproj][0m
2021-04-04T20:36:18.5356631Z [37m/tmp/oryx/platforms/dotnet/5.0.103/sdk/5.0.103/NuGet.targets(131,5): error : Response status code does not indicate success: 401 (Unauthorized). [/working_dir/scream4meV2.AdminTool/scream4meV2.AdminTool.csproj][0m
2021-04-04T20:36:20.3764297Z [37m[0m
2021-04-04T20:36:20.3764743Z [37m[0m
2021-04-04T20:36:20.3765151Z [37m---End of Oryx build logs---[0m
2021-04-04T20:36:20.3775107Z [31mOryx has failed to build the solution.[0m
2021-04-04T20:36:20.4140308Z [37m[0m
Most helpful comment
@krisnuttall To get around this for now, build your app in separate steps and use the AzureStaticWebApp task to publish only. To do this, set the
app_locationto the build output location from the previous step (build,dist, etc). Leaveoutput_locationempty.