private bool IsTestProject(Project project)
        {
            if (PackageInstallerServices.IsPackageInstalled(project, "NUnit"))
            {
                return(true);
            }
            if (PackageInstallerServices.IsPackageInstalled(project, "xunit"))
            {
                return(true);
            }
            if (PackageInstallerServices.IsPackageInstalled(project, "MSTest.TestFramework"))
            {
                return(true);
            }

            // MSTests or referenced directly?
            if (!(project.Object is VSProject3 vsProject))
            {
                return(false);
            }

            foreach (Reference reference in vsProject.References)
            {
                switch (reference.Name)
                {
                case "Microsoft.VisualStudio.TestPlatform.TestFramework":
                case "nunit.framework":
                case "xunit.core":
                    return(true);
                }
            }

            return(false);
        }
        public async override Task AddNugetPackages()
        {
            await this.Context.Logger.WriteMessageAsync(LoggerMessageCategory.Information, "Adding Nuget Packages");

            var wcfDSInstallLocation = CodeGeneratorUtils.GetWCFDSInstallLocation();
            var packageSource        = Path.Combine(wcfDSInstallLocation, @"bin\NuGet");

            if (Directory.Exists(packageSource))
            {
                var files = Directory.EnumerateFiles(packageSource, "*.nupkg").ToList();
                foreach (var nugetPackage in Common.Constants.V3NuGetPackages)
                {
                    if (!files.Any(f => Regex.IsMatch(f, nugetPackage + @"(.\d){2,4}.nupkg")))
                    {
                        packageSource = Common.Constants.NuGetOnlineRepository;
                    }
                }
            }
            else
            {
                packageSource = Common.Constants.NuGetOnlineRepository;
            }

            if (!PackageInstallerServices.IsPackageInstalled(this.Project, this.ClientNuGetPackageName))
            {
                Version packageVersion = null;
                PackageInstaller.InstallPackage(Common.Constants.NuGetOnlineRepository, this.Project, this.ClientNuGetPackageName, packageVersion, false);
            }
        }
Beispiel #3
0
        public override async Task AddNugetPackages()
        {
            await this.Context.Logger.WriteMessageAsync(LoggerMessageCategory.Information, "Adding Nuget Packages");

            if (!PackageInstallerServices.IsPackageInstalled(this.Project, this.ClientNuGetPackageName))
            {
                Version packageVersion = null;
                PackageInstaller.InstallPackage(Common.Constants.NuGetOnlineRepository, this.Project, this.ClientNuGetPackageName, packageVersion, false);
            }
        }
 internal async Task CheckAndInstallNuGetPackageAsync(string packageSource, string nugetPackage)
 {
     try
     {
         if (!PackageInstallerServices.IsPackageInstalled(this.Project, nugetPackage))
         {
             PackageInstaller.InstallPackage(packageSource, this.Project, nugetPackage, (Version)null, false);
             await this.Context.Logger.WriteMessageAsync(LoggerMessageCategory.Information, $"Nuget Package \"{nugetPackage}\" forOpenAPI (Swagger) was added.");
         }
         else
         {
             await this.Context.Logger.WriteMessageAsync(LoggerMessageCategory.Information, $"Nuget Package \"{nugetPackage}\" for OpenAPI (Swagger) already installed.");
         }
     }
     catch (Exception ex)
     {
         await this.Context.Logger.WriteMessageAsync(LoggerMessageCategory.Warning, $"Nuget Package \"{nugetPackage}\" for OpenAPI (Swagger) not installed. Error: {ex.Message}.");
     }
 }
        internal async Task CheckAndInstallNuGetPackageAsync(string packageSource, string nugetPackage)
        {
            try
            {
                if (!PackageInstallerServices.IsPackageInstalled(this.Project, nugetPackage))
                {
                    Version packageVersion = null;
                    PackageInstaller.InstallPackage(packageSource, this.Project, nugetPackage, packageVersion, false);

                    await this.Context.Logger.WriteMessageAsync(LoggerMessageCategory.Information, $"Nuget Package \"{nugetPackage}\" for OData client was added.");
                }
                else
                {
                    await this.Context.Logger.WriteMessageAsync(LoggerMessageCategory.Information, $"Nuget Package \"{nugetPackage}\" for OData client already installed.");
                }
            }
            catch (Exception ex)
            {
                await this.Context.Logger.WriteMessageAsync(LoggerMessageCategory.Error, $"Nuget Package \"{nugetPackage}\" for OData client not installed. Error: {ex.Message}.");
            }
        }
 public bool IsPackageInstalled(EnvDTE.Project project, string packageId)
 {
     return(PackageInstallerServices.IsPackageInstalled(project, packageId));
 }
 private bool HasSmartAnalyzer(Project project) => PackageInstallerServices.IsPackageInstalled(project, "SmartTests.Analyzer");
 private bool IsSmartProject(Project project) => PackageInstallerServices.IsPackageInstalled(project, "SmartTests");