0

I want to deploy an Angular application to an Azure Static Web Application.The build part works fine but the release errors and says it can not find the build artifact : Directory Location: 'dist' is invalid. Could not detect this directory. Please verify your deployment configuration file reflects your repository structure.

This is the YAML used for the application publish, screenshot below that.

steps:
- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: dist'
  inputs:
    PathtoPublish: dist
    ArtifactName: dist

Static Web App templete

So it seems that we are not using the correct publish location but not sure what to use.

The following is the YAML from the pipeline :

steps:
- task: Npm@1
  displayName: 'npm custom'
  inputs:
    command: custom
    verbose: false
    customCommand: 'install @angular/cli -g'

steps:
- task: Npm@1
  displayName: 'npm install'
  inputs:
    verbose: false

steps:
- task: Npm@1
  displayName: 'npm build'
  inputs:
    command: custom
    verbose: false
    customCommand: 'run build -- --configuration=production'

steps:
- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: dist'
  inputs:
    PathtoPublish: dist/CarehomeBooking
    ArtifactName: dist

The directory structure of the built Angular app is :

AngularBuiltCode

2
  • Could you please share your Pipeline code and directory structure of your artifact? Commented Aug 11, 2021 at 9:54
  • Added details above to my original question. Commented Aug 11, 2021 at 17:51

1 Answer 1

2

The PathToPublish needs to have the output folder of the ng build action. Please make sure to build a release version of your project. You might need to run either ng build --prod, ng build --configuration production or simply ng build to make sure you build a release version depending on what version of Angular (CLI) you are on.

The default output path for current Angular projects is: dist/<projectName>

Find your output path by opening up the angular.json file and looking at the outputPath under architect -> build -> options.

Also: make sure you run the command from the root of the project or specify the full path.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi, I tried making some of your suggested changes but I now get the error : 2021-08-11T17:07:51.4931321Z [37mDetecting platforms...[0m 2021-08-11T17:09:00.4466669Z [31mError: Oops... An unexpected error has occurred.[0m
I have added a screenshot of the built Angular artefact to the original question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.