Search code examples
asp.net-core.net-coregithub-actionsdotnet-clidotnet-bundle

dotnet bundle on GitHub Action


I am trying to run dotnet bundle on my .Net Core 2.1 GitHub Action. The action with the error shown below:

Run cd ./ProjName
  cd ./ProjName
  dotnet bundle
  shell: /bin/bash -e {0}
  env:
    DOTNET_ROOT: /home/runner/.dotnet
No executable found matching command "dotnet-bundle"

The project is using BundlerMinifierCore for minification. This should build the minified files when the command is run.

I'm pretty new to GitHub actions and am getting used to pulling in everything the project needs to build. Am I missing the .Net CLI tools or something of the sort?

The YAML is as follows:

name: Build and Deploy Develop

on:
  push:
    branches: [ develop ]
  pull_request:
    branches: [ develop ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Setup .NET
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 2.1.x
    - name: Restore dependencies
      run: |
        cd ./ProjName
        dotnet restore
    - name: Build
      run:  |
        cd ./ProjName
        dotnet build --no-restore
    - name: Bundle JS and CSS Assets
      run:  |
        cd ./ProjName
        dotnet bundle
    - name: Test
      run:   |
        cd ./ProjName
        dotnet test --no-build --verbosity normal
    - name: Build Linux
      run:  |
        cd ./ProjName
        dotnet publish -c Release --self-contained true --runtime linux-x64 --framework netcoreapp2.1 /p:useapphost=true
    - name: Copy Files to Develop
      uses: garygrossgarten/github-action-scp@release
      with:
        local: ./ProjName/ProjName.WebApp/bin/Release/netcoreapp2.1/linux-x64/publish
        remote: /home/deploy/ProjName/develop/staging
        host: ${{ secrets.DEPLOY_SERVER }}
        username: deploy
        port: 22509
        privateKey: ${{ secrets.SSH_PRIVATE_KEY }}
    - name: Call deploy.sh on Server
      uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.DEPLOY_SERVER }}
        port: 22509
        username: deploy
        key: ${{ secrets.SSH_PRIVATE_KEY }}
        script: "sudo /var/aspnetcore/ProjName/develop/deploy.sh"

Solution

  • It looks like you are trying to use the dotnet bundle tool without installing it.

    Try installing it after installing .NET. Something like this:

        - name: Setup .NET
          uses: actions/setup-dotnet@v1
          with:
            dotnet-version: 2.1.x
        # only this is new
        - name: Install dotnet tools
          run: |
            dotnet tool install -g BundlerMinifier.Core
        - name: Restore dependencies
          run: |
            cd ./ProjName
            dotnet restore