anchor.diff:          await dummyDir.create();
   
           final pubspecFile = File(p.join(dummyDir.path, 'pubspec.yaml'));
  -        await pubspecFile
  -            .writeAsString(_generateDummyPubspec(package.name, version));
  +        await pubspecFile.writeAsString(_generateDummyPubspec(
  +          package.name,
  +          version,
  +          minSdkVersion: toolEnv.runtimeInfo.sdkVersion,
  +        ));
   
  -        final pr = await Process.run(
  -          'pub',
  -          ['get'],
  -          environment: {
  -            'PUB_CACHE': pubCacheDir.path,
  -          },
  -          workingDirectory: dummyDir.path,
  -        );
  +        final pr = await toolEnv.runUpgrade(dummyDir.path, false);
           if (pr.exitCode != 0) {
             throw Exception(
                 'pub get on `${package.name} $version` exited with ${pr.exitCode}.\n${pr.stderr}');
  
positive.code: import 'dart:io';
  
  import 'package:basics/basics.dart';
  import 'package:path/path.dart' as p;
  import 'package:pub_dev/shared/utils.dart';
  
  import 'models.dart';
  
negative.code:     final pubCacheDir = Directory(p.join(temp.path, 'pub-cache'));
      await pubCacheDir.create();
  
      final toolEnv = await ToolEnvironment.create(
        dartSdkDir: envConfig.toolEnvDartSdkDir,
        flutterSdkDir: envConfig.flutterSdkDir,
        pubCacheDir: pubCacheDir.path,
      );
  
      for (final package in profile.packages) {
        final versions = package.versions == null || package.versions.isEmpty
            ? <String>['any']
  