Exemplo n.º 1
0
        public void CreatePackage(DevEnv type, out string standardOutput, out string standardError)
        {
            VerifyCloudServiceProjectComponents();
            CsPack packageTool = new CsPack();

            packageTool.CreatePackage(Components.Definition, Paths.RootPath, type, out standardOutput, out standardError);
        }
Exemplo n.º 2
0
 public AzureService(string rootPath, string scaffoldingPath)
 {
     SetScaffolding(scaffoldingPath);
     Paths       = new ServicePathInfo(rootPath);
     Components  = new ServiceComponents(Paths);
     packageTool = new CsPack();
     runTool     = new CsRun();
 }
Exemplo n.º 3
0
        public void CreatePackage(DevEnv type)
        {
            string standardOutput, standardError;

            VerifyCloudServiceProjectComponents();
            CsPack packageTool = new CsPack();

            packageTool.CreatePackage(Components.Definition, Paths, type, AzureTool.GetAzureSdkBinDirectory(), out standardOutput, out standardError);
        }
        public void CreatePackage(DevEnv type)
        {
            string standardOutput, standardError;

            VerifyCloudServiceProjectComponents();
            CsPack packageTool = new CsPack();

            packageTool.CreatePackage(Components.Definition, Paths, type, AzureTool.GetAzureSdkBinDirectory(), out standardOutput, out standardError);
            if (!string.IsNullOrWhiteSpace(standardError))
            {
                //The error of invalid xpath expression about endpoint in the configuration file is expected. Hence, we do not throw.
                if (!standardError.Contains("/RoleEnvironment/CurrentInstance/Endpoints/Endpoint[@name='HttpIn']/@port"))
                {
                    throw new InvalidOperationException(string.Format(Properties.Resources.FailedToCreatePackage, standardError));
                }
            }
        }
Exemplo n.º 5
0
        public AzureService(string serviceParentDirectory, string name, string scaffoldingPath) : this()
        {
            Validate.ValidateDirectoryFull(serviceParentDirectory, Resources.ServiceParentDirectory);
            Validate.ValidateStringIsNullOrEmpty(name, "Name");
            Validate.ValidateFileName(name, string.Format(Resources.InvalidFileName, "Name"));
            Validate.ValidateDnsName(name, "Name");

            string newServicePath = Path.Combine(serviceParentDirectory, name);

            if (Directory.Exists(newServicePath))
            {
                throw new ArgumentException(string.Format(Resources.ServiceAlreadyExistsOnDisk, name, newServicePath));
            }

            packageTool = new CsPack();
            SetScaffolding(scaffoldingPath);
            Paths = new ServicePathInfo(newServicePath);
            CreateNewService(Paths.RootPath, name);
            Components = new ServiceComponents(Paths);
            ConfigureNewService(Components, Paths, name);
        }
        void RetrieveRightErrorFromCsPackProcess()
        {
            string serviceName     = "AzureService";
            string sampleError     = "error";
            string stagingFolder   = FileSystemHelper.GetTemporaryDirectoryName();
            string fakedSDKBinPath = @"c:\foobar";

            Directory.CreateDirectory(stagingFolder);
            try
            {
                CloudServiceProject service = new CloudServiceProject(stagingFolder, serviceName, null);
                service.AddWorkerRole(Test.Utilities.Common.Data.NodeWorkerRoleScaffoldingPath);
                CsPack packTool = new CsPack();
                string standardOutput, standardError;

                //Scenario #1 we set up so cspack.exe fails (exitcode is 1), but gives out the error through standardOutput.
                Mock <ProcessHelper> commandRunner = new Mock <ProcessHelper>();
                commandRunner.Setup(p => p.StartAndWaitForProcess(It.IsAny <string>(), It.IsAny <string>()))
                .Callback(() => {
                    commandRunner.Object.StandardOutput = sampleError;
                    commandRunner.Object.StandardError  = "";
                    commandRunner.Object.ExitCode       = 1;
                });
                packTool.ProcessUtil = commandRunner.Object;

                //action
                packTool.CreatePackage(service.Components.Definition, service.Paths, DevEnv.Local, fakedSDKBinPath, out standardOutput, out standardError);

                //assert we take "standardoutput" as the error message
                Assert.Equal(sampleError, standardError);

                //Scenario #2: set up so cspack.exe succeed (exitcode is 0)
                commandRunner = new Mock <ProcessHelper>();
                commandRunner.Setup(p => p.StartAndWaitForProcess(It.IsAny <string>(), It.IsAny <string>()))
                .Callback(() =>
                {
                    commandRunner.Object.StandardOutput = sampleError;
                    commandRunner.Object.StandardError  = string.Empty;
                    commandRunner.Object.ExitCode       = 0;
                });
                packTool.ProcessUtil = commandRunner.Object;

                //action
                packTool.CreatePackage(service.Components.Definition, service.Paths, DevEnv.Local, fakedSDKBinPath, out standardOutput, out standardError);

                //assert, we outputs no error
                Assert.Equal(string.Empty, standardError);

                //Sceanrio 3: set up so cspack.exe failed (exitcode is 1), but gives out no ouput and error
                commandRunner = new Mock <ProcessHelper>();
                commandRunner.Setup(p => p.StartAndWaitForProcess(It.IsAny <string>(), It.IsAny <string>()))
                .Callback(() =>
                {
                    commandRunner.Object.StandardOutput = string.Empty;
                    commandRunner.Object.StandardError  = string.Empty;
                    commandRunner.Object.ExitCode       = 1;
                });
                packTool.ProcessUtil = commandRunner.Object;

                //action
                packTool.CreatePackage(service.Components.Definition, service.Paths, DevEnv.Local, fakedSDKBinPath, out standardOutput, out standardError);

                //assert, we output a generic error message
                Assert.Equal(Resources.CsPackExeGenericFailure, standardError);
            }
            finally
            {
                Directory.Delete(stagingFolder, true);
            }
        }
 public void CreatePackage(DevEnv type, out string standardOutput, out string standardError)
 {
     VerifyCloudServiceProjectComponents();
     CsPack packageTool = new CsPack();
     packageTool.CreatePackage(Components.Definition, Paths, type, AzureTool.GetAzureSdkBinDirectory(), out standardOutput, out standardError);
 }
 public void CreatePackage(DevEnv type, out string standardOutput, out string standardError)
 {
     VerifyCloudServiceProjectComponents();
     CsPack packageTool = new CsPack();
     packageTool.CreatePackage(Components.Definition, Paths.RootPath, type, out standardOutput, out standardError);
 }
Exemplo n.º 9
0
        public void CreatePackage(DevEnv type, out string standardOutput, out string standardError)
        {
            var packageTool = new CsPack();

            packageTool.CreatePackage(Components.Definition, Paths.RootPath, type, out standardOutput, out standardError);
        }