diff --git a/buildpacks/dotnet/CHANGELOG.md b/buildpacks/dotnet/CHANGELOG.md index eedf1219..d8f6b58c 100644 --- a/buildpacks/dotnet/CHANGELOG.md +++ b/buildpacks/dotnet/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- The buildpack log output now includes more launch process detection and registration details. ([#124](https://github.com/heroku/buildpacks-dotnet/pull/124)) - The `PublishDir` MSBuild property is now set to `bin/publish` when running `dotnet publish`, to ensure that the publish output for each project is consistently sent to the same location (relative to the project file). This enables writing `Procfile` commands that are compatible with any target OS/arch (i.e. Runtime Identifier (RID)), build configuration (e.g. `Release`/`Debug`) and Target Framework Moniker (TFM). ([#120](https://github.com/heroku/buildpacks-dotnet/pull/121)) ## [0.1.1] - 2024-08-19 diff --git a/buildpacks/dotnet/src/main.rs b/buildpacks/dotnet/src/main.rs index b773dcba..98fa6efc 100644 --- a/buildpacks/dotnet/src/main.rs +++ b/buildpacks/dotnet/src/main.rs @@ -19,7 +19,7 @@ use crate::dotnet_buildpack_configuration::{ use crate::dotnet_publish_command::DotnetPublishCommand; use crate::launch_process::LaunchProcessDetectionError; use crate::layers::sdk::SdkLayerError; -use bullet_stream::state::Bullet; +use bullet_stream::state::{Bullet, SubBullet}; use bullet_stream::{style, Print}; use fun_run::CommandWithName; use indoc::formatdoc; @@ -66,6 +66,7 @@ impl Buildpack for DotnetBuildpack { } } + #[allow(clippy::too_many_lines)] fn build(&self, context: BuildContext) -> libcnb::Result { let buildpack_configuration = DotnetBuildpackConfiguration::try_from(&Env::from_current()) .map_err(DotnetBuildpackError::ParseBuildpackConfiguration)?; @@ -162,17 +163,32 @@ impl Buildpack for DotnetBuildpack { layers::runtime::handle(&context, &sdk_layer.path())?; - let mut build_result_builder = BuildResultBuilder::new(); - match launch_process::detect_solution_processes(&solution) { + log_bullet = log + .bullet("Setting launch table") + .sub_bullet("Detecting process types from published artifacts"); + let mut launch_builder = LaunchBuilder::new(); + log = match launch_process::detect_solution_processes(&solution) { Ok(processes) => { - // TODO: Print log information about registered processes - build_result_builder = - build_result_builder.launch(LaunchBuilder::new().processes(processes).build()); + if processes.is_empty() { + log_bullet = log_bullet.sub_bullet("No processes were detected"); + } + for process in processes { + log_bullet = log_bullet.sub_bullet(format!( + "Added {}: {}", + style::value(process.r#type.to_string()), + process.command.join(" ") + )); + launch_builder.process(process); + } + log_bullet.done() } - Err(error) => log = log_launch_process_detection_warning(error, log), - } + Err(error) => log_launch_process_detection_warning(error, log_bullet), + }; log.done(); - build_result_builder.build() + + BuildResultBuilder::new() + .launch(launch_builder.build()) + .build() } fn on_error(&self, error: libcnb::Error) { @@ -252,33 +268,35 @@ fn detect_global_json_sdk_version_requirement( fn log_launch_process_detection_warning( error: LaunchProcessDetectionError, - log: Print>, + log: Print>, ) -> Print> { match error { - LaunchProcessDetectionError::ProcessType(process_type_error) => log.warning(formatdoc! {" - {process_type_error} + LaunchProcessDetectionError::ProcessType(process_type_error) => log + .warning(formatdoc! {" + {process_type_error} - Launch process detection error + Launch process detection error - We detected an invalid launch process type. + We detected an invalid launch process type. - The buildpack automatically tries to register Cloud Native Buildpacks (CNB) - process types for console and web projects after successfully publishing an - application. + The buildpack automatically tries to register Cloud Native Buildpacks (CNB) + process types for console and web projects after successfully publishing an + application. - Process type names are based on the filenames of compiled project executables, - which is usually the project name. For example, `webapi` for a `webapi.csproj` - project. In some cases, these names are be incompatible with the CNB spec as - process types can only contain numbers, letters, and the characters `.`, `_`, - and `-`. + Process type names are based on the filenames of compiled project executables, + which is usually the project name. For example, `webapi` for a `webapi.csproj` + project. In some cases, these names are be incompatible with the CNB spec as + process types can only contain numbers, letters, and the characters `.`, `_`, + and `-`. - To use this automatic launch process type registration, see the warning details - above to troubleshoot and make necessary adjustments. + To use this automatic launch process type registration, see the warning details + above to troubleshoot and make necessary adjustments. - If you think you found a bug in the buildpack, or have feedback on improving - the behavior for your use case, file an issue here: - https://github.com/heroku/buildpacks-dotnet/issues/new - "}), + If you think you found a bug in the buildpack, or have feedback on improving + the behavior for your use case, file an issue here: + https://github.com/heroku/buildpacks-dotnet/issues/new + "}) + .done(), } }