actions / setup-dotnet

Set up your GitHub Actions workflow with a specific version of the .NET core sdk
MIT License
943 stars 458 forks source link

[Info] dotnet ^7.0.2* introduced an MSBuild preview version with breaking changes. #383

Closed snwflake closed 1 year ago

snwflake commented 1 year ago

Description: For reference: https://github.com/dotnet/sdk/issues/30624

The MSBuild preview version provided with 7.0.200 introduced breaking changes and generally ill-formed behavior.

Pinning the version to anything below 7.0.200, ie. 7.0.103 does not resolve that issue, as the same MSBuild preview is still being used.

My workaround so far has been to add another step after the dotnet-setup which just removes 7.0.2* sdk versions. Only then started my build to produce working output with proper viewcomponents.

Task version: 926f442

Platform:

Runner type:

Repro steps:

- name: Setup .net
  uses: actions/setup-dotnet@v3
  with:
    dotnet-version: 7.0.103
dotnet publish app -c Release -o ~/deploy
MSBuild version 17.5.0-preview-23061-01+040e2a90e for .NET

Notes: While this is a bug introduced by the SDK, I still wanted to raise this issue here, to spare others from wasting 3 hours debugging it. The workaround for me is currently the following until the announced hotfix 7.0.201 goes live:

- name: Setup .net
  uses: actions/setup-dotnet@v3
  with:
    dotnet-version: 7.0.103
- name: Remove faulty SDK version
  run: sudo rm -rf /usr/share/dotnet/sdk/7.0.2*
panticmilos commented 1 year ago

hi @snwflake, thank you for the report, we will take a look at it :)

danielriddellsh commented 1 year ago

Typo in your fix, should be -rf otherwise it errors with: rm: cannot remove '/usr/share/dotnet/sdk/7.0.200': Is a directory

snwflake commented 1 year ago

@danielriddellsh sorry, should have copy&pasted.

Shane32 commented 1 year ago

7.0.201 has been released but it’s not picked up by setup-dotnet. Anyone know what’s up?

edumserrano commented 1 year ago

I just wanted to leave here that one of the workarounds described here worked for me.

What I did was make use of a global.json file to pin the version of dotnet to 7.0.103. I also had to make sure that my dotnet CLI commands were picking up the global.json file. See the note below.

This fixed the issue for me without having to remove the default installation of dotnet SDK 7.0.200 from the GitHub runner. I just need to make sure that the actions/setup-dotnet@v3 installs a previous working version such as 7.0.103. You can review here an example of the PRs I've made on my repos to fix this issue: edumserrano/github-issue-forms-parser#28.

Note

As per the global.json overview docs: "The .NET SDK looks for a global.json file in the current working directory (which isn't necessarily the same as the project directory) or one of its parent directories."

This means that you need to be careful regarding what the working directory where you run the dotnet CLI commands is to make sure the global.json file is respected.

stunney commented 1 year ago

6.0.* also has breaking issues with dotnet pack --output as well. This is due to a preview version of MSBuild being tacked onto the setup-dotnet GHA that I don't think was intended.

https://github.com/dotnet/core/issues/8245

AZ-X commented 1 year ago

It's a terrible release, isn't it? I gotter face strange NETSDK1168 unexpectedly...

tgrnwd commented 1 year ago

My experience seems to be that running any dotnet command in conjunction with v3 of this action is using the latest SDK, even though I specify 6.0.x in the setup-dotnet action.

Falling back to v2 of this action produces the expected behavior.

IvanZosimov commented 1 year ago

Hi, @tgrnwd 👋 The v3 release contains some breaking changes and it's behaviour is different from v2 version. Please, refer to this part of documentation to get additional information https://github.com/actions/setup-dotnet#usage.

tgrnwd commented 1 year ago

@IvanZosimov Ah, thank you. I'm certain I read this, but didn't fully understand at that time.

IvanZosimov commented 1 year ago

I'm closing this issue as the NET SDK 7.0.201 was released and it seems to solve the problem.