Deploy website to azure with bower dependencies

前端 未结 3 1879
醉酒成梦
醉酒成梦 2020-12-16 21:35

I have an ASPNET mvc project using both Nuget and Bower for dependencies. Now I need to either trigger bower to install components upon deployment or as fallback include the

相关标签:
3条回答
  • 2020-12-16 22:05

    All of Azure Websites workers have bower pre-installed and should be on your path.

    All you need to do is add a custom deployment script that would do bower install Here is a sample repo for an ASP.NET MVC site that uses bower

    Basically make sure bower.json is there and referenced in your csproj

        <Content Include="bower.json" />
    

    Then download your custom deployment script. if you go to https://<yourSiteName>.scm.azurewebsites.net then click on Tools -> Download custom deployment script or just download it from D:\home\deployment\tools then check it in the root of your repo like here basically there will be 2 files deploy.cmd and .deployment

    this is the deployment logic, add a step to restore bower in it like here after the last step there

    :: 4. Bower Install
    if EXIST "%DEPLOYMENT_TARGET%\bower.json" (
        pushd "%DEPLOYMENT_TARGET%"
        call :ExecuteCmd bower install
        IF !ERRORLEVEL! NEQ 0 goto error
        popd
    )
    
    0 讨论(0)
  • 2020-12-16 22:05

    You can use the console feature of Azure web app to fire the commands. Even if the console has access to a restricted features, you can still install the bower components by using the command:

    bower install
    

    The console option is listed under the deployment section of the Web Apps. You can refer the below the screen for reference.

    Prerequisites:

    1. Do not publish the bowerComponents folder to the Web app.
    2. Include the bower.json file including all the dependencies.

    Hope it helps.

    0 讨论(0)
  • 2020-12-16 22:08

    One important addition to the above - you must push both the unchanged .deployment file and modified .cmd file to deployment root for Azure to subsequently copy/execute your .cmd amendments. Otherwise it will regenerate a default .cmd

    0 讨论(0)
提交回复
热议问题