コード例 #1
0
        public DeploymentResults Deploy(Project project)
        {
            DeploymentPackage package = null;
            DeploymentEnvironment environment = null;

            try
            {
                // Compile the project first before we attempt to deploy it.
                DeploymentResults compileResults = project.Compile();
                if (!compileResults.Successful)
                {
                    // Is the compile was unsuccesfull, return the results
                    return compileResults;
                }

                // Create a logger that is required by the deployment package
                ProjectLogger logger = new ProjectLogger();
                logger.Verbosity = Microsoft.Build.Framework.LoggerVerbosity.Diagnostic;
                project.SetOutputLogger(logger);

                // Create a new deployment package
                package = project.CreateDeploymentPackage();

                // The deployment package requires at least one environment, so add a default one.
                // When deployment is done via VisualStudio, the environments are automatically set
                // up from the ones available in the Environment Library.
                environment = package.AddEnvironment("Default");
                package.SelectedEnvironment = environment.Name;
                package.SmartObjectConnectionString = _smartObjectConnectionString;
                package.WorkflowManagementConnectionString = _workflowManagementConnectionString;

                // Start the deployment
                return project.Deploy(package);
            }
            finally
            {
                if (package != null)
                {
                    package.Dispose();
                    package = null;
                }
                if (environment != null)
                {
                    environment.Dispose();
                    environment = null;
                }
            }
        }
コード例 #2
0
        public void BeginBatch_CanLogMultipleWriteLines()
        {
            var logger = new ProjectLogger()
            {
                IsEnabled = true
            };

            using (var batch = ProjectLoggerExtensions.BeginBatch(logger))
            {
                batch.WriteLine("Line1");
                batch.IndentLevel = 1;
                batch.WriteLine("Line2");
                batch.IndentLevel = 0;
                batch.WriteLine("Line3");
            }

            // NOTE: No trailing new line, as the logger itself should be adding it
            Assert.Equal("Line1\r\n    Line2\r\nLine3", logger.Text, ignoreLineEndingDifferences: true);
        }