I faced with the same issue when trying to get dotnet and git paths added into the %PATH% on servercore:2019 Was able overcome it by
RUN cmd /C "setx /M PATH \"%PATH%;C:\\Program Files\\Git\\cmd;C:\\Program Files\\dotnet\""