Visual Studio can build the docker image, but command line can't

I am new in docker container. I have the latest docker desktop on my Windows PC. I have two asp.net core projects in a Visual Studio solution. Their dockerfiles are the same:

FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019
ARG source
WORKDIR /inetpub/wwwroot
COPY ${source:-obj/Docker/publish} .

The docker-compose file at the solution level is:

version: '3.4'

services:
  mywebsite:
    image: frankscontainerregistry.azurecr.io/mywebsite
    build:
      context: .\MyWebsite
      dockerfile: Dockerfile
    depends_on:
      - myapi

  myapi:
    image: frankscontainerregistry.azurecr.io/myapi
    build:
      context: .\MyAPI
      dockerfile: Dockerfile

If I run the docker-compose on Visual Studio, it can build the two images OK. But if I open a CMD window and run “docker-compose build”, it always stuck indefinitely on the following step:

C:\Users\xxx\repos\Two containers>docker-compose build
[+] Building 0.0s (0/0)
Sending build context to Docker daemon     524B
Step 1/6 : FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019
 ---> e2460dcda92c
[+] Building 0.0s (0/0)
[+] Building 0.0s (0/0)
Removing intermediate container 59e2d7901d9b
 ---> 433f15103f76
[+] Building 0.0s (0/0)
[+] Building 0.0s (0/0)
Removing intermediate container 5cda0ccea357
 ---> db0acea79f98
[+] Building 0.0s (0/0)       

What is the problem?