async Task ExecuteAsync(CancellationToken cancellationToken)
        {
            if (Version == null)
            {
                ResolvedPackage resolvedPackage = await GetLatestPackageVersion(PackageId, cancellationToken);

                Version = resolvedPackage?.LatestVersion;
            }

            var identity = new PackageIdentity(PackageId, Version);

            var resolutionContext = CreateResolutionContext();

            actions = await packageManager.PreviewInstallPackageAsync(
                project,
                identity,
                resolutionContext,
                context,
                primarySources,
                secondarySources,
                cancellationToken);

            if (LicensesMustBeAccepted)
            {
                await CheckLicenses(cancellationToken);
            }

            if (ShouldOpenReadmeFile(identity))
            {
                packageManager.SetDirectInstall(identity, context);
            }

            using (IDisposable fileMonitor = CreateFileMonitor()) {
                using (var referenceMaintainer = CreateProjectReferenceMaintainer()) {
                    await packageManager.ExecuteNuGetProjectActionsAsync(
                        project,
                        actions,
                        context,
                        resolutionContext.SourceCacheContext,
                        cancellationToken);

                    if (referenceMaintainer != null)
                    {
                        await referenceMaintainer.ApplyChanges();
                    }
                }
            }

            packageManager.ClearDirectInstall(context);

            project.OnAfterExecuteActions(actions);

            await project.RunPostProcessAsync(context, cancellationToken);
        }
        async Task ExecuteAsync(CancellationToken cancellationToken)
        {
            if (Version == null)
            {
                Version = await GetLatestPackageVersion(PackageId, cancellationToken);
            }

            var identity = new PackageIdentity(PackageId, Version);

            actions = await packageManager.PreviewInstallPackageAsync(
                project,
                identity,
                CreateResolutionContext(),
                context,
                primarySources,
                secondarySources,
                cancellationToken);

            if (LicensesMustBeAccepted)
            {
                await CheckLicenses(cancellationToken);
            }

            if (OpenReadmeFile)
            {
                packageManager.SetDirectInstall(identity, context);
            }

            using (IDisposable fileMonitor = CreateFileMonitor()) {
                using (IDisposable referenceMaintainer = CreateLocalCopyReferenceMaintainer()) {
                    await packageManager.ExecuteNuGetProjectActionsAsync(
                        project,
                        actions,
                        context,
                        cancellationToken);
                }
            }

            packageManager.ClearDirectInstall(context);

            project.OnAfterExecuteActions(actions);

            await project.RunPostProcessAsync(context, cancellationToken);
        }