Use the latest Nuget Tool version for .NET 6
Asked by Victor H Garcia:

How can I use the latest version of the nuget tool when restoring the packages of a .NET 6 project? I noticed it is using old version that is preventing to restore successfully all my project packages.

Any hint is always welcome, please.

btw, On Azure DevOps, I got recommended to use:  
**- task: NuGetToolInstaller@1**  
However, I don't know how to use it on Bitbucket Pipelines.  
Thanks in advance,  
Victor


Answers:
author: Caroline R
body: Hi, Victor, thank you for reaching out to Atlassian Community.

In order to properly assist you, could you please share the following information with us?

* What build image are you using?

* Which Nuget are you using?

* What error/behavior are you getting?

Thank you!

Kind regards,  
Caroline

comments: author: Victor H Garcia
body: Thanks [@Caroline R](/t5/user/viewprofilepage/user-id/3934006) for your response.

<br />

The **bitbucket-pipelines.yml** I'm using is the following:

<br />

```
image: microsoft/dotnet:sdk

pipelines:

branches:

develop:

 - step:

name: Build

caches:

 - dotnetcore

script:

 - dotnet restore src/solution_name.sln

 - dotnet build src/solution_name.sln --no-restore --configuration Release
```

<br />

The error, I'm getting is:

> Images used:  
> build : docker.io/microsoft/dotnet@sha256:4db9513d5b1bcf4b88c5700f9b831908d435d9771fd28a338b123e5ab8eec036  
> + dotnet restore src/solution_name.sln  
> /opt/atlassian/pipelines/agent/build/src/project/project_name.csproj : error NU1202: Package MVCCaching.Kentico.Core 13.0.2 is not compatible with net60 (.NETFramework,Version=v6.0). Package MVCCaching.Kentico.Core 13.0.2 supports: netcoreapp3.1 (.NETCoreApp,Version=v3.1) \[/opt/atlassian/pipelines/agent/build/src/solution_name.sln\]  
> Restore failed in 1.25 sec for /opt/atlassian/pipelines/agent/build/src/project/project_name.csproj.  
> /opt/atlassian/pipelines/agent/build/src/project2/project_name_2.csproj : error NU

Basically, what I want to build is a project on **.NET 6** ASP.NET MVC project, however, I tried to use well the following images without luck. The image I was setting is **mcr.microsoft.com/dotnet/core/sdk:6.0** however, I got the following error:

rpc error: code = NotFound desc = failed to pull and unpack image "mcr.microsoft.com/dotnet/core/sdk:6.0": failed to resolve reference "mcr.microsoft.com/dotnet/core/sdk:6.0": mcr.microsoft.com/dotnet/core/sdk:6.0: not found  
Let me know if you need anything else from me.  
Kind Regards,  
Victor


author: Caroline R
body: Hi, Victor.

Thanks for getting back to us and sharing the additional information. Before we continue, I just would like to set the expectation that we are not proficient with how .Net technology works, but we will assist as best as possible from our side.

In order for us to verify if the issue is related to the Pipeline, you will need to debug the build locally and let us know the result. You can access the following link to check how to perform this test:

* [Debug pipelines locally with Docker](https://support.atlassian.com/bitbucket-cloud/docs/debug-pipelines-locally-with-docker/)

The error that you are getting while pulling the image **mcr.microsoft.com/dotnet/core/sdk:6.0** is actually expected as the image you are specifying doesn't exist. Could you please try to use **mcr.microsoft.com/dotnet/sdk:6.0** to pull the image if you would like to use the .Net SDK 6.0 version as mentioned [here](https://hub.docker.com/_/microsoft-dotnet-sdk)?

Please let us know how it goes and don't hesitate to ask for any further information if needed.

Kind regards,   
Caroline


author: Victor H Garcia
body: Hello [@Caroline R](/t5/user/viewprofilepage/user-id/3934006) ,

Thank you for your help! By updating the image to the one you shared on the comment, the build of my .NET 6 project worked very good.

Thank you so much for sharing the debugging details as well. I will definitely configure it locally for tests.

Regards,  
Victor


author: Caroline R
body: Hi, Victor!

Thanks for getting back to us! I'm glad to know it worked :)

Kind regards,   
Caroline


Tags: .net

bitbucket-cloud

bitbucket-pipelines

cloud