示例#1
0
        public void SetupPowerShellEnvironment(System.Management.Automation.PowerShell powerShell, string credentials, string profile)
        {
            powerShell.RemoveCredentials();
            string profileFile = Path.Combine(this.downloadDirectoryPath, profile);

            if (File.Exists(profileFile))
            {
                string dest = Path.Combine(AzurePowerShell.ProfileDirectory, profile);
                powerShell.AddScript(string.Format("Copy-Item -Path '{0}' -Destination '{1}' -Force", profileFile, dest));
                powerShell.AddScript("[Microsoft.WindowsAzure.Commands.Utilities.Common.AzureProfile]::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]);
            }
        }
示例#2
0
 public static void ImportCredentails(System.Management.Automation.PowerShell powerShell, string credentialFile)
 {
     powerShell.RemoveCredentials();
     powerShell.ImportCredentials(credentialFile);
 }