Ejemplo n.º 1
0
        internal override void UpdateEnvironmentVariables()
        {
            base.UpdateEnvironmentVariables();

            var oldItems = Items;

            Items = new List <string>();
            foreach (string item in oldItems)
            {
                StringBuilder s = new StringBuilder(item);
                foreach (KeyValuePair <string, string> envVar in this.EnvironmentVariables)
                {
                    s.Replace(envVar.Key, envVar.Value);
                }
                string res = s.ToString();
                if (res.IndexOf(":") > 0)
                {
                }
                else
                {
                    if (EnvironmentVariables.ContainsKey("$(ProjectDir)"))
                    {
                        res = Path.GetFullPath(EnvironmentVariables["$(ProjectDir)"] + res);
                    }
                }
                Items.Add(res);
            }
        }
Ejemplo n.º 2
0
        protected override void Initialize(Project project)
        {
            webProject = project.GetFlavor <DotNetCoreProjectExtension> ()?.IsWeb ?? false;
            base.Initialize(project);
            ExternalConsole = !webProject;
            if (!webProject)
            {
                return;
            }
            // Pick up/import default values from "launchSettings.json"
            var launchSettingsJsonPath = Path.Combine(project.BaseDirectory, "Properties", "launchSettings.json");
            var launchSettingsJson     = File.Exists(launchSettingsJsonPath) ? JObject.Parse(File.ReadAllText(launchSettingsJsonPath)) : null;
            var settings = (launchSettingsJson?.GetValue("profiles") as JObject)?.GetValue(project.Name) as JObject;

            LaunchBrowser = settings?.GetValue("launchBrowser")?.Value <bool?> () ?? true;
            LaunchUrl     = settings?.GetValue("launchUrl")?.Value <string> () ?? null;
            foreach (var pair in (settings?.GetValue("environmentVariables") as JObject)?.Properties() ?? Enumerable.Empty <JProperty> ())
            {
                if (!EnvironmentVariables.ContainsKey(pair.Name))
                {
                    EnvironmentVariables.Add(pair.Name, pair.Value.Value <string> ());
                }
            }
            ApplicationURL = settings?.GetValue("applicationUrl")?.Value <string> () ?? "http://localhost:5000/";
        }
Ejemplo n.º 3
0
 public string GetEnvValue(string key, string defaultValue = "")
 {
     if (EnvironmentVariables.ContainsKey(key))
     {
         return(EnvironmentVariables[key]);
     }
     return(defaultValue);
 }
Ejemplo n.º 4
0
        internal override void UpdateEnvironmentVariables()
        {
            base.UpdateEnvironmentVariables();

            if (OutDir != string.Empty)
            {
                StringBuilder s = new StringBuilder(OutDir);
                foreach (KeyValuePair <string, string> envVar in this.EnvironmentVariables)
                {
                    s.Replace(envVar.Key, envVar.Value);
                }
                string res = s.ToString();
                if (res.IndexOf(":") > 0)
                {
                }
                else
                {
                    if (EnvironmentVariables.ContainsKey("$(ProjectDir)"))
                    {
                        res = Path.GetFullPath(EnvironmentVariables["$(ProjectDir)"] + res);
                    }
                }
                OutDir = res;
            }

            if (IntDir != string.Empty)
            {
                StringBuilder s = new StringBuilder(IntDir);
                foreach (KeyValuePair <string, string> envVar in this.EnvironmentVariables)
                {
                    s.Replace(envVar.Key, envVar.Value);
                }
                string res = s.ToString();
                if (res.IndexOf(":") > 0)
                {
                }
                else
                {
                    if (EnvironmentVariables.ContainsKey("$(ProjectDir)"))
                    {
                        res = Path.GetFullPath(EnvironmentVariables["$(ProjectDir)"] + res);
                    }
                }
                IntDir = res;
            }

            if (TargetName != string.Empty)
            {
                StringBuilder s = new StringBuilder(TargetName);
                foreach (KeyValuePair <string, string> envVar in this.EnvironmentVariables)
                {
                    s.Replace(envVar.Key, envVar.Value);
                }
                string res = s.ToString();
                TargetName = res;
            }
        }
Ejemplo n.º 5
0
        protected override void Configure()
        {
            AddExposedPort(MySqlPort);
            AddEnv("MYSQL_DATABASE", DatabaseName);
            AddEnv("MYSQL_USER", UserName);
            AddEnv("MYSQL_PASSWORD", Password);

            if (!EnvironmentVariables.ContainsKey("MYSQL_ROOT_PASSWORD"))
            {
                AddEnv("MYSQL_ROOT_PASSWORD", "root-secret");
            }
        }
Ejemplo n.º 6
0
 protected override void Write(IPropertySet pset)
 {
     base.Write(pset);
     pset.SetValue(nameof(ExternalConsole), ExternalConsole, false);
     pset.SetValue(nameof(LaunchBrowser), LaunchBrowser, true);
     pset.SetValue(nameof(LaunchUrl), string.IsNullOrWhiteSpace(LaunchUrl) ? null : LaunchUrl, null);
     pset.SetValue(nameof(ApplicationURL), ApplicationURL, "http://localhost:5000/");
     if (EnvironmentVariables.Count == 1 && EnvironmentVariables.ContainsKey("ASPNETCORE_ENVIRONMENT") && EnvironmentVariables ["ASPNETCORE_ENVIRONMENT"] == "Development")
     {
         pset.RemoveProperty(nameof(EnvironmentVariables));
     }
 }
        protected override void Write(IPropertySet pset)
        {
            base.Write(pset);
            pset.SetValue(nameof(ExternalConsole), ExternalConsole, !webProject);
            if (!webProject)
            {
                return;
            }
#pragma warning disable CS0618 // Type or member is obsolete
            pset.SetValue(nameof(LaunchBrowser), LaunchBrowser, true);
            pset.SetValue(nameof(LaunchUrl), string.IsNullOrWhiteSpace(LaunchUrl) ? null : LaunchUrl, null);
            pset.SetValue(nameof(ApplicationURL), ApplicationURL, "http://localhost:5000/");
#pragma warning restore CS0618 // Type or member is obsolete
            if (EnvironmentVariables.Count == 1 && EnvironmentVariables.ContainsKey("ASPNETCORE_ENVIRONMENT") && EnvironmentVariables ["ASPNETCORE_ENVIRONMENT"] == "Development")
            {
                pset.RemoveProperty(nameof(EnvironmentVariables));
            }
        }
        internal override void UpdateEnvironmentVariables()
        {
            base.UpdateEnvironmentVariables();

            List <string> oldInc = IncludeDirectories;

            IncludeDirectories = new List <string>();
            foreach (string dir in oldInc)
            {
                StringBuilder s = new StringBuilder(dir);
                foreach (KeyValuePair <string, string> envVar in EnvironmentVariables)
                {
                    s.Replace(envVar.Key, envVar.Value);
                }
                string res = s.ToString();
                if (res.IndexOf(":") > 0)
                {
                }
                else
                {
                    if (EnvironmentVariables.ContainsKey("$(ProjectDir)"))
                    {
                        res = Path.GetFullPath(EnvironmentVariables["$(ProjectDir)"] + res);
                    }
                }
                IncludeDirectories.Add(res);
            }

            List <string> oldPreprocessors = Preprocessors;

            Preprocessors = new List <string>();
            foreach (string processor in oldPreprocessors)
            {
                StringBuilder s = new StringBuilder(processor);
                foreach (KeyValuePair <string, string> envVar in EnvironmentVariables)
                {
                    s.Replace(envVar.Key, envVar.Value);
                }
                string res = s.ToString();
                Preprocessors.Add(res);
            }
        }
Ejemplo n.º 9
0
        protected override void Initialize(Project project)
        {
            base.Initialize(project);
            ExternalConsole = false;
            // Pick up/import default values from "launchSettings.json"
            var launchSettingsJsonPath = Path.Combine(project.BaseDirectory, "Properties", "launchSettings.json");
            var launchSettingsJson     = File.Exists(launchSettingsJsonPath) ? JObject.Parse(File.ReadAllText(launchSettingsJsonPath)) : null;
            var settings = (launchSettingsJson?.GetValue("profiles") as JObject)?.GetValue(project.Name) as JObject;

            LaunchBrowser = settings?.GetValue("launchBrowser")?.Value <bool?> () ?? true;
            LaunchUrl     = settings?.GetValue("launchUrl")?.Value <string> () ?? null;
            foreach (var pair in (settings?.GetValue("environmentVariables") as JObject)?.Properties() ?? Enumerable.Empty <JProperty> ())
            {
                if (!EnvironmentVariables.ContainsKey(pair.Name))
                {
                    EnvironmentVariables.Add(pair.Name, pair.Value.Value <string> ());
                }
            }
            ApplicationURL = GetApplicationUrl(settings, EnvironmentVariables);
        }
Ejemplo n.º 10
0
        protected override void Write(IPropertySet pset)
        {
            base.Write(pset);

            pset.SetValue(nameof(ExternalConsole), ExternalConsole, false);
            if (EnvironmentVariables.Count == 1 && EnvironmentVariables.ContainsKey("ASPNETCORE_ENVIRONMENT") && EnvironmentVariables ["ASPNETCORE_ENVIRONMENT"] == "Development")
            {
                pset.RemoveProperty(nameof(EnvironmentVariables));
            }

            if (CurrentProfile == null)
            {
                return;
            }

            CurrentProfile.EnvironmentVariables.Clear();
            foreach (var pair in EnvironmentVariables)
            {
                CurrentProfile.EnvironmentVariables [pair.Key] = pair.Value;
            }

            launchProfileProvider?.SaveLaunchSettings(Profiles.ToSerializableForm());
        }
Ejemplo n.º 11
0
        protected override void Write(IPropertySet pset)
        {
            base.Write(pset);

            pset.SetValue(nameof(ExternalConsole), ExternalConsole, false);
            if (EnvironmentVariables.Count == 1 && EnvironmentVariables.ContainsKey("ASPNETCORE_ENVIRONMENT") && EnvironmentVariables ["ASPNETCORE_ENVIRONMENT"] == "Development")
            {
                pset.RemoveProperty(nameof(EnvironmentVariables));
            }

            if (CurrentProfile == null)
            {
                return;
            }

            CurrentProfile.EnvironmentVariables.Clear();
            foreach (var pair in EnvironmentVariables)
            {
                CurrentProfile.EnvironmentVariables [pair.Key] = pair.Value;
            }

            OnSaveRequested();

#pragma warning disable CS0618
            // persist values to Run Configuration for backward compatibility
            pset.SetValue(nameof(LaunchBrowser), CurrentProfile.LaunchBrowser, true);
            pset.SetValue(nameof(LaunchUrl), string.IsNullOrWhiteSpace(CurrentProfile.LaunchUrl) ? null : CurrentProfile.LaunchUrl, null);
            var appUrl = CurrentProfile.TryGetApplicationUrl();
            if (!string.IsNullOrEmpty(appUrl))
            {
                pset.SetValue(nameof(ApplicationURL), appUrl, "http://localhost:5000/");
            }
#pragma warning restore CS0618

            IsDirty = false;
        }