GitLab - CI/CD - Both dotnet, dotnet-core images

My .Net solution has .net core 2.2 project which refers multiple .net framework (4.6.1) projects. I am trying to setup CI/CD in gitlab, but getting error and I am not sure how to use two images for a job.

.gitlab-ci.yml:

stages:
    - build

    
variables:
    PROJECT_NAME: "Admin.API"
    BUILD_IMAGE: "mcr.microsoft.com/dotnet/core/sdk:3.1"
    DOTNET_IMAGE: microsoft/dotnet:latest
    
before_script:
    - echo "pre script"
    - echo Sourcecode/API/Admin.API
    - "cd Sourcecode/API/Admin.API"
    - "dotnet restore"
    
build:
    stage:  build
    
    image: $DOTNET_IMAGE
    image: $BUILD_IMAGE
    script:
        - echo "Building"
        - dotnet build --configuration Release      

Error while running job:

/usr/share/dotnet/sdk/3.1.302/Microsoft.Common.CurrentVersion.targets(1177,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks

Please help me on this.
Thank you.

Hi @naveendhasarathan, did you found a solution to the problem?