Skip to content

ReadMe Guides for generating a temporary global.json are incorrect for Windows- CMD vs PWSH #683

@SimonDarksideJ

Description

@SimonDarksideJ

Description:
A clear and concise description of what the bug is.
We ran in to an issue with the instructions in the readme for generating a global.json in our automated repository (to force dotnet 9 in a dotnet 10 workd)

Matrix testing with temporary global.json creation

However, the default shell for windows is "cmd" which results in an escape file output containing single quotes

'{ "sdk": { "version": "9.0.304" } }'

In DotNet 9 and above, this results in a malformed global.json and will break any automation running dotnet commands using it.

To resolve this

The documentation should make clear that the shell should be changed to pwsh which outputs the global.json correctly.

Task version:
5

Platform:

  • Ubuntu
  • macOS
  • [ X] Windows

Runner type:

  • Hosted
  • [ X] Self-hosted

Repro steps:

Simply use the instructions on a windows host without setting a shell or using "cmd"

      - name: Create temporary global.json
        run: echo '{"sdk":{"version": "${{ steps.stepid.outputs.dotnet-version }}"}}' > ./global.json

      - name: Create temporary global.json
        run: echo '{"sdk":{"version": "${{ steps.stepid.outputs.dotnet-version }}"}}' > ./global.json
        shell: cmd

To make the command work correctly, the instructions should INSIST that PWSH or bash is used on windows (where supported)

      - name: Create temporary global.json
        run: echo '{"sdk":{"version": "${{ steps.stepid.outputs.dotnet-version }}"}}' > ./global.json
        shell: pwsh

Expected behavior:
A well formed json should be generated using the instructions

Actual behavior:
dotnet commands fail due to a malformed json configuration

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions