void AddNuGetPackageReference(IDotNetProject project, string packageId) { var packageRepoFactory = new PackageRepositoryFactory(); var packageRepo = packageRepoFactory.CreateRepository("http://www.nuget.org/api/v2/"); var packageManagementProjectFactory = new PackageManagementProjectFactory(PackageManagementServices.PackageManagementEvents); var packageManagementProject = packageManagementProjectFactory.CreateProject(packageRepo, project); var package = packageRepo.FindPackagesById(packageId).FirstOrDefault(x => x.IsLatestVersion); var packageManagerFactory = new SharpDevelopPackageManagerFactory(); var packageManager = packageManagerFactory.CreatePackageManager(packageRepo, project); packageManager.InstallPackage(package, false, false); packageManagementProject.AddPackageReference(package); }
void CreatePackageManager() { fakePackageRepository = new FakePackageRepository(); packageManager = factory.CreatePackageManager(fakePackageRepository, testProject); }