We analyze a nonlocal PDE model describing the dynamics of adaptation of a phenotypically structured population, under the effects of mutation and selection, in a changing environment. Previous studies have analyzed the large-time behavior of such models, with particular forms of environmental changes, either linearly changing or periodically fluctuating. We use here a completely different mathematical approach, which allows us to consider very general forms of environmental variations and to give an analytic description of the full trajectories of adaptation, including the transient phase, before a stationary behavior is reached. The main idea behind our approach is to study a bivariate distribution of two 'fitness components' which contains enough information to describe the distribution of fitness at any time. This distribution solves a degenerate parabolic equation that is dealt with by defining a multidimensional cumulant generating function associated with the distribution, and solving the associated transport equation.We apply our results to several examples, and check their accuracy, using stochastic individual-based simulations as a benchmark. These examples illustrate the importance of being able to describe the transient dynamics of adaptation to understand the development of drug resistance in pathogens.