public void SetupPowerShellEnvironment(PowerShell powerShell, string credentials, string profile)
        {
            powerShell.RemoveCredentials();
            string profileFile = Path.Combine(this.downloadDirectoryPath, profile);

            if (File.Exists(profileFile))
            {
                string dest = Path.Combine(GlobalPathInfo.GlobalSettingsDirectory, profile);
                powerShell.AddScript(string.Format("Copy-Item -Path '{0}' -Destination '{1}' -Force", profileFile, dest));
                powerShell.AddScript("[Microsoft.WindowsAzure.Commands.Utilities.Common.WindowsAzureProfile]::Instance.Load()");
            }
            else
            {
                string credentialFile = Path.Combine(this.downloadDirectoryPath, credentials);
                Assert.IsTrue(File.Exists(credentialFile), string.Format("Did not download file {0}", credentialFile));
                Console.WriteLine("Using default.PublishSettings for setting up credentials");
                powerShell.ImportCredentials(credentialFile);
            }

            foreach (string key in this.environment.Keys)
            {
                powerShell.AddEnvironmentVariable(key, environment[key]);
            }
            foreach (string key in this.PowerShellVariables.Keys)
            {
                powerShell.SetVariable(key, PowerShellVariables[key]);
            }
        }
 public void SetupPowerShellEnvironment(PowerShell powerShell, string credentials)
 {
     powerShell.RemoveCredentials();
     string credentialFile = Path.Combine(this.downloadDirectoryPath, credentials);
     Assert.IsTrue(File.Exists(credentialFile), string.Format("Did not download file {0}", credentialFile));
     powerShell.ImportCredentials(credentialFile);
     foreach (string key in this.environment.Keys) powerShell.AddEnvironmentVariable(key, environment[key]);
     foreach (string key in this.PowerShellVariables.Keys) powerShell.SetVariable(key, PowerShellVariables[key]);
 }
Exemplo n.º 3
0
        public void SetupPowerShellEnvironment(PowerShell powerShell, string credentials)
        {
            powerShell.RemoveCredentials();
            string credentialFile = Path.Combine(this.downloadDirectoryPath, credentials);

            Assert.IsTrue(File.Exists(credentialFile), string.Format("Did not download file {0}", credentialFile));
            powerShell.ImportCredentials(credentialFile);
            foreach (string key in this.environment.Keys)
            {
                powerShell.AddEnvironmentVariable(key, environment[key]);
            }
            foreach (string key in this.PowerShellVariables.Keys)
            {
                powerShell.SetVariable(key, PowerShellVariables[key]);
            }
        }
        public void SetupPowerShellEnvironment(PowerShell powerShell, string credentials, string profile)
        {
            powerShell.RemoveCredentials();
            string profileFile = Path.Combine(this.downloadDirectoryPath, profile);

            if (File.Exists(profileFile))
            {
                string dest = Path.Combine(GlobalPathInfo.GlobalSettingsDirectory, profile);
                powerShell.AddScript(string.Format("Copy-Item -Path '{0}' -Destination '{1}' -Force", profileFile, dest));
                powerShell.AddScript("[Microsoft.WindowsAzure.Commands.Utilities.Common.WindowsAzureProfile]::Instance.Load()");
            }
            else
            {
                string credentialFile = Path.Combine(this.downloadDirectoryPath, credentials);
                Assert.IsTrue(File.Exists(credentialFile), string.Format("Did not download file {0}", credentialFile));
                Console.WriteLine("Using default.PublishSettings for setting up credentials");
                powerShell.ImportCredentials(credentialFile);
            }

            foreach (string key in this.environment.Keys) powerShell.AddEnvironmentVariable(key, environment[key]);
            foreach (string key in this.PowerShellVariables.Keys) powerShell.SetVariable(key, PowerShellVariables[key]);
        }