Extremum-seeking control (ESC) is a useful tool for the steady-state performance optimization of plants for which limited knowledge about its dynamical behavior and disturbance situation is known. The case when the steady-state plant responses correspond to equilibrium solutions received a lot of attention. However, in many industrial applications plant performance is characterized by time-varying steady-state behavior. In those cases, no static parameter-to-steady-state performance map can be defined. In this work, we propose an ESC method that employs a so-called dynamic cost function to cope with time-varying steady-state responses of general nonlinear systems. We prove semi-global practical asymptotic stability of the closed-loop ESC scheme in the presence of bounded and time-varying external disturbances. Moreover, the working principle is illustrated by means of the real-time performance optimal tuning of a nonlinear control strategy for a motion control application.