1

I have cloned Sitecore docker-examples repository and started to go through tutorial of building custom images Building Custom Sitecore images.

I noticed that when I use the command docker-compose build solution, it throws and error about not finding a certain NuGet package:

Error on console

Error text is below (slightly different than image above but same error).

C:\build\Directory.Build.targets : error : Could not resolve SDK "Microsoft.Build.CentralPackageVersions". Exactly one of the probing messages below indicates why we could not resolve the SDK. Investigate and resolve that message to correctly specify the SDK.
C:\build\Directory.Build.targets : error :   C:\Program Files\dotnet\sdk\7.0.302\Sdks\Microsoft.Build.CentralPackageVersions\Sdk not found. Check that a recent enough .NET SDK is installed and/or increase the version specified in global.json.
C:\build\Directory.Build.targets : error :   Unable to find package Microsoft.Build.CentralPackageVersions. No packages exist with this id in source(s): nuget.org, Sitecore Feed
C:\build\Directory.Build.targets : error :   MSB4276: The default SDK resolver failed to resolve 
SDK "Microsoft.Build.CentralPackageVersions" because directory "C:\Program Files (x86)\Microsoft 
Visual Studio\2022\BuildTools\MSBuild\Sdks\Microsoft.Build.CentralPackageVersions\Sdk" did not exist.
C:\build\Directory.Build.targets : warning : Unable to load the service index for source https://api.nuget.org/v3/index.json.
C:\build\Directory.Build.targets : warning : Unable to load the service index for source https://sitecore.myget.org/F/sc-packages/api/v3/index.json.
C:\build\Directory.Build.targets : error MSB4236: The SDK 'Microsoft.Build.CentralPackageVersions/2.0.79' specified could not be found. [C:\build\src\Foundation\Search\website\Foundation.Search.csproj]

I did open the example solution on VS2019 and published the project to directory and it works, so does build solution. I checked that the package is indeed in nuget.org, so how come it cannot find it? However, it's not installed to these projects in solution and Package Manager does not allow me to do that, it's only referenced in Directory.Build.targets. Why am I getting this error?

Error is: The SDK 'Microsoft.Buikd.CentralPackageVersions/2.0.79' specified could not be found.

1

3 Answers 3

1

Unable to load the service index for source would seem to be the key error here. It likely indicates that your container is unable to access the internet, or your network has proxy requirements which you need to add to your NuGet.config.

One other potential solution is fixing the interface metric of your network adapter:

You can fix this by setting your primary internet-connected networking adapter to have the lowest InterfaceMetric value:

CopyGet-NetIPInterface -AddressFamily IPv4 | Sort-Object -Property InterfaceMetric -Descending`

Use this command to make the change (this example assumes primary adapter InterfaceAlias is 'Wi-Fi'):

CopySet-NetIPInterface -InterfaceAlias 'Wi-Fi' -InterfaceMetric 3

If your host's primary network adapter is bridged because you have an External virtual switch setup in Hyper-V, set the external virtual switch to have the lowest InterfaceMetric value.

You may wish to try running the Sitecore Container Prerequisites troubleshooting tool.

1
  • Thank you Nick. That was the issue for mine. After running those scripts the error went away.
    – Mhoque
    Nov 11, 2021 at 17:39
0

Disconnect from your corporate VPN, or add network allow rules for nuget.org and myget.org. In my experience, corporate VPNs can be a consistent issue when fetching packages. If this is the case for you, contact your IT admins.

-2

I managed to fix this error by installing .NET 5.0.4 and restarting PC. I checked the folder after command 'docker-compose build solution' does "Microsoft.Buikd.CentralPackageVersions" folder appear inside "dotnet/sdks/5.0.4" folder but it does not. But still this fixed the error. Strange that console shows many different errors but this was the one that fixed all of them.

2
  • What you have installed on your host PC has absolutely no bearing on your docker-compose build process. Other than Docker Desktop itself, obviously.
    – Mark Cassidy
    Oct 4, 2021 at 0:42
  • Well I do understand with docker it shouldn't, but I have no other explanation why it started to work. Dec 7, 2021 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.