I’m currently creating GitHub Action pipelines for building and testing multiple solutions within a single large monorepo. These solutions target a variety of .NET versions so in order to allow them all to run in my pipeline I need to include install all the required versions.

This worked fine using v2 of the actions/setup-dotnet@v2 action for .NET versions 5 and 6.

- name: Setup .NET
  uses: actions/setup-dotnet@v2
  with:
    dotnet-version: |
      5.0.x
      6.0.x 

However when I tried to include 3.1.x as well the action failed to install it. In order to try and resolve the issue I upgraded the action version to v3 which then gave me the following error.

mkdir: cannot create directory ‘usr/share/dotnet’: Permission denied

It appears that when running in an Ubuntu runner that it tries to install .NET in a directory to which it doesn’t have permission. This can be resolved by specifying the install directory for .NET in the environment variable DOTNET_INSTALL_DIR

jobs:
  test:
    runs-on: ununtu-latest
  env:
    DOTNET_INSTALL_DIR: "./.dotnet"
  steps:
    - name: Setup .NET
      uses: actions/setup-dotnet@v2
      with:
        dotnet-version: |
          3.1.x
          5.0.x
          6.0.x 

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *