예제 #1
0
        public Task Build(DeploymentContext context)
        {
            var tcs = new TaskCompletionSource <object>();

            ILogger innerLogger = context.Logger.Log(Resources.Log_PreparingFiles);

            try
            {
                using (context.Tracer.Step("Copying files to output directory"))
                {
                    // Copy to the output path and use the previous manifest if there
                    DeploymentHelper.CopyWithManifest(_sourcePath, context.OutputPath, context.PreviousMainfest);
                }

                using (context.Tracer.Step("Building manifest"))
                {
                    // Generate a manifest from those build artifacts
                    context.ManifestWriter.AddFiles(_sourcePath);
                }

                // Log the copied files from the manifest
                innerLogger.LogFileList(context.ManifestWriter.GetPaths());
            }
            catch (Exception ex)
            {
                context.Tracer.TraceError(ex);

                context.GlobalLogger.Log(ex);

                innerLogger.Log(ex);

                tcs.SetException(ex);

                // Bail out early
                return(tcs.Task);
            }

            try
            {
                // Download node packages
                DownloadNodePackages(context);

                AddIISNodeConfig(context);

                tcs.SetResult(null);
            }
            catch (Exception ex)
            {
                context.Tracer.TraceError(ex);

                // HACK: Log an empty error to the global logger (post receive hook console output).
                // The reason we don't log the real exception is because the 'live output' when downloding
                // npm packages has already been captured.
                context.GlobalLogger.LogError();

                tcs.SetException(ex);
            }

            return(tcs.Task);
        }
예제 #2
0
        protected override Task BuildProject(DeploymentContext context)
        {
            var     tcs        = new TaskCompletionSource <object>();
            ILogger copyLogger = context.Logger.Log(Resources.Log_PreparingFiles);

            try
            {
                using (context.Tracer.Step("Copying files to output directory"))
                {
                    // Copy to the output path
                    DeploymentHelper.CopyWithManifest(_projectPath, context.OutputPath, context.PreviousMainfest);
                }

                using (context.Tracer.Step("Building manifest"))
                {
                    // Generate the manifest from the project path
                    context.ManifestWriter.AddFiles(_projectPath);
                }

                // Log the copied files from the manifest
                copyLogger.LogFileList(context.ManifestWriter.GetPaths());

                tcs.SetResult(null);
            }
            catch (Exception ex)
            {
                context.Tracer.TraceError(ex);

                context.GlobalLogger.Log(ex);

                copyLogger.Log(ex);

                tcs.SetException(ex);
            }

            return(tcs.Task);
        }
예제 #3
0
        public override Task Build(DeploymentContext context)
        {
            var    tcs           = new TaskCompletionSource <object>();
            string buildTempPath = Path.Combine(_tempPath, Guid.NewGuid().ToString());

            ILogger buildLogger = context.Logger.Log(Resources.Log_BuildingWebProject, Path.GetFileName(_projectPath));

            try
            {
                using (context.Tracer.Step("Running msbuild on project file"))
                {
                    string log = BuildProject(context.Tracer, buildTempPath);

                    // Log the details of the build
                    buildLogger.Log(log);
                }
            }
            catch (Exception ex)
            {
                context.Tracer.TraceError(ex);

                // HACK: Log an empty error to the global logger (post receive hook console output).
                // The reason we don't log the real exception is because the 'live output' running
                // msbuild has already been captured.
                context.GlobalLogger.LogError();

                buildLogger.Log(ex);

                tcs.SetException(ex);

                return(tcs.Task);
            }

            ILogger copyLogger = context.Logger.Log(Resources.Log_PreparingFiles);

            try
            {
                using (context.Tracer.Step("Copying files to output directory"))
                {
                    // Copy to the output path and use the previous manifest if there
                    DeploymentHelper.CopyWithManifest(buildTempPath, context.OutputPath, context.PreviousMainfest);
                }

                using (context.Tracer.Step("Building manifest"))
                {
                    // Generate a manifest from those build artifacts
                    context.ManifestWriter.AddFiles(buildTempPath);
                }

                // Log the copied files from the manifest
                copyLogger.LogFileList(context.ManifestWriter.GetPaths());

                tcs.SetResult(null);
            }
            catch (Exception ex)
            {
                context.Tracer.TraceError(ex);

                context.GlobalLogger.Log(ex);

                copyLogger.Log(ex);

                tcs.SetException(ex);
            }
            finally
            {
                // Clean up the build artifacts after copying them
                CleanBuild(context.Tracer, buildTempPath);
            }

            return(tcs.Task);
        }