Пример #1
0
 async Task CheckCertificateThenExecute(ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
 {
     if (AspNetCoreCertificateManager.CheckDevelopmentCertificateIsTrusted(Project, runConfiguration))
     {
         await AspNetCoreCertificateManager.TrustDevelopmentCertificate(monitor);
     }
     await base.OnExecute(monitor, context, configuration, runConfiguration);
 }
        LaunchProfileData CreateProfile(string name)
        {
            var defaultProfile = new LaunchProfileData {
                Name                 = name,
                CommandName          = "Project",
                LaunchBrowser        = true,
                EnvironmentVariables = new Dictionary <string, string> (StringComparer.Ordinal),
                OtherSettings        = new Dictionary <string, object> (StringComparer.Ordinal)
            };

            defaultProfile.EnvironmentVariables.Add("ASPNETCORE_ENVIRONMENT", "Development");
            var anyConfigurationUsesHttps = false;

            foreach (var runConfiguration in project.RunConfigurations)
            {
                if (AspNetCoreCertificateManager.UsingHttps(runConfiguration))
                {
                    anyConfigurationUsesHttps = true;
                    break;
                }
            }

            string applicationUrl;

            var httpPort  = GetNextFreePort();
            var httpsPort = GetNextFreePort();

            if (anyConfigurationUsesHttps)
            {
                applicationUrl = $"https://localhost:{httpsPort};http://localhost:{httpPort}";
            }
            else
            {
                applicationUrl = $"http://localhost:{httpPort}";
            }

            defaultProfile.OtherSettings.Add("applicationUrl", applicationUrl);

            return(defaultProfile);
        }