actions / runner-images

GitHub Actions runner images
MIT License
10.1k stars 3.04k forks source link

Projects with Sdk="MSBuild.Sdk.Extras" are failing #5766

Closed qwertylolman closed 2 years ago

qwertylolman commented 2 years ago

Description

Xamarin solution with multitarget project configured via Sdk="MSBuild.Sdk.Extras" are failing on restore Nuget step with errors:

error : Unable to resolve 'MSBuild.Sdk.Extras (= 3.0.44)' for '.NETStandard,Version=v0.0'. error : /Users/runner/work/_temp/dotnet/sdk/5.0.408/Sdks/MSBuild.Sdk.Extras/Sdk not found. Check that a recent enough .NET SDK is installed and/or increase the version specified in global.json. error MSB4236: The SDK 'MSBuild.Sdk.Extras' specified could not be found.

Changing of the sdk versions didn't help

Platforms affected

Virtual environments affected

Image version and build link

20220614.2

Is it regression?

20220605.1

Expected behavior

Build didn't fails

Actual behavior

Build fails

Repro steps

  1. Create Xamarin solution with multitarget project that uses MSBuild.Sdk.Extras (any version) and global.json
  2. Try to restore nugets in pipeline via NuGetCommand@2 task with 'restore' command
qwertylolman commented 2 years ago

this issue is critical, as it fail the builds for our internal framework and few applications. one of this application planned to go live in next few days

qwertylolman commented 2 years ago

seems to be working on macos-10.15 agent so i'm pretty sure it's an msbuild 16.10.1.31401 still we cannot downgrade, because of Xamarin.Ios

mikhailkoliada commented 2 years ago

@qwertylolman Hi!

Could you please provide us a minimalistic pipeline and an msbuild spec to reproduce the issue?

akoeplinger commented 2 years ago

This looks like the same underlying issue as https://github.com/actions/virtual-environments/issues/5768 i.e. the nuget.config being wrong/empty.

qwertylolman commented 2 years ago

This looks like the same underlying issue as #5768 i.e. the nuget.config being wrong/empty.

no, it's not. i spent few hours diagnosing my issue. we previously had the same nuget version (6.2.1.2) installed via - task: NuGetToolInstaller@1 displayName: "Installing NuGet tool"

more likely it's because of msbuild version. as it's was the only thing that was changed in current release and can affect us. also macos-10.15 agent had MSBuild 16.10.1.58001 two days ago and was able to build the solution sucessfully (well, except for the outdated xcode and xamarin versions). while macos-11 agent has MSBuild 16.10.1.31401.

also, our other solutions without multitarget projects has no issues. we have like 6 app in development phase right now, and two of them has multitarget projects. both are failing in pipeline for now.

another thing that was changed is the .net sdk 3.1.420, which previously was 3.1.419. but this shouldn't affect our pipelines as we have steps to install .net sdk 3.1.416 which we are using for builds. also i tried few other .net sdk versions incuding 5.0.408 and i still have the same issue.

and as temporary workaround, for most critical application as for now, i splitted multitarget projects into core+platform specific projects. and it worked. but we cannot do this for all our applications with multitarget.

qwertylolman commented 2 years ago

@qwertylolman Hi!

Could you please provide us a minimalistic pipeline and an msbuild spec to reproduce the issue?

not sure i can provide you the pipeline. the failed step looks like this: - task: NuGetCommand@2 displayName: "Restoring project's NuGets" inputs: command: 'restore' restoreSolution: ${{ parameters.solutionPath }} feedsToUse: 'select' vstsFeed: ${{ parameters.vstsFeed }}

where parameters.vstsFeed is out internal feed deployed in Azure. It also has copies of required packages from nuget.org, and to exclude issue with nuget tool i tried to add "includeNuGetOrg: true" before NugetCommand@2 we have some extra steps, but i'm sure they shouldn't affect the pipeline:

- custom sh script to get installed Xamarin versions for diagnostic which basically do the ls command
- task: UseDotNet@2
        inputs:
          packageType: 'sdk'
          version: '$(XamarinDotNetVersion)'
          installationPath: '$(Agent.TempDirectory)/dotnet'

- script: |
          /bin/bash -c "sudo $(Agent.HomeDirectory)/scripts/select-xamarin-sdk-v2.sh --mono=$(MonoSdkVersion) --ios=$(XamarinIosSdkVersion) --android=$(XamarinAndroidSdkVersion)"
akoeplinger commented 2 years ago

@qwertylolman can you add a step to your pipeline that prints the contents of ~/.config/NuGet/NuGet.Config, i.e. before you run any of your actual build steps ?

If that file has an empty <packageSources> element then it is the same issue as #5768

qwertylolman commented 2 years ago

@qwertylolman can you add a step to your pipeline that prints the contents of ~/.config/NuGet/NuGet.Config, i.e. before you run any of your actual build steps ?

If that file has an empty <packageSources> element then it is the same issue as #5768

ok, assuming you are right. how would you explain this? the same solution, one with multitarget projects, other has platform specific projects and another order of tasks (moved install sdk, etc closer to the start of the job) instead of multitarget

Screenshot 2022-06-21 at 14 20 39 Screenshot 2022-06-21 at 14 40 50
qwertylolman commented 2 years ago

@qwertylolman can you add a step to your pipeline that prints the contents of ~/.config/NuGet/NuGet.Config, i.e. before you run any of your actual build steps ?

If that file has an empty <packageSources> element then it is the same issue as #5768

also here is the ouput from failed nuget restore task /Library/Frameworks/Mono.framework/Versions/Current/Commands/mono /Users/runner/hostedtoolcache/NuGet/6.2.1/x64/nuget.exe sources Add -NonInteractive -Name FooBarFeed -Source https://foobar.dev.azure.com/foobar/_packaging/foobar/nuget/v3/index.json -ConfigFile /Users/runner/work/1/Nuget/tempNuGet_2204124.config Package source with Name: FooBarFeed added successfully. /Library/Frameworks/Mono.framework/Versions/Current/Commands/mono /Users/runner/hostedtoolcache/NuGet/6.2.1/x64/nuget.exe sources Add -NonInteractive -Name NuGetOrg -Source https://api.nuget.org/v3/index.json -ConfigFile /Users/runner/work/1/Nuget/tempNuGet_2204124.config Package source with Name: NuGetOrg added successfully. /Library/Frameworks/Mono.framework/Versions/Current/Commands/mono /Users/runner/hostedtoolcache/NuGet/6.2.1/x64/nuget.exe restore /Users/runner/work/1/s/src/FooBar.sln -Verbosity Detailed -NonInteractive -ConfigFile /Users/runner/work/1/Nuget/tempNuGet_2204124.config

qwertylolman commented 2 years ago

ok, we added nuget.config to our solution and magic happened. it's building for now. but i still don't get why it's working without multitarget projects and with empty ~/.config/NuGet/NuGet.Config

akoeplinger commented 2 years ago

Hmm not sure why it works in one case and not the other, but the root cause for your issue is still the malformed nugget.config

SVetrichelvan commented 2 years ago

We placed the nuget file at the root of the Xamarin solution and that solved the problem.

File Name: Nuget.config

<?xml version="1.0" encoding="UTF-8"?>

miketimofeev commented 2 years ago

@SVetrichelvan @qwertylolman another possible option is to remove the broken nuget config from the user's home directory before restoring the packages rm -rf ~/.config/NuGet/NuGet.Config Sorry for the inconvenience, the new image with the fix will be deployed in a few days.

mikhailkoliada commented 2 years ago

The fix has been deployed.

qwertylolman commented 2 years ago

Confirmed, fixed. Thank you! Btw, we found another workaround - add nuget.config with nuget.org and our azre feed to solution