@@ -142,81 +142,95 @@ func (pa *packageAction) Run(ctx context.Context) (*actions.ActionResult, error)
142142 return nil , err
143143 }
144144
145- packageResults := map [string ]* project.ServicePackageResult {}
146-
147145 serviceTable , err := pa .importManager .ServiceStable (ctx , pa .projectConfig )
148146 if err != nil {
149147 return nil , err
150148 }
149+
151150 serviceCount := len (serviceTable )
152- for index , svc := range serviceTable {
153- // TODO(ellismg): We need to figure out what packaging an containerized dotnet app means. For now, just skip it.
154- // We "package" the app during deploy when we call `dotnet publish /p:PublishProfile=DefaultContainer` to build
155- // and push the container image.
156- //
157- // Doing this skip here means that during `azd up` we don't show output like:
158- // /* cSpell:disable */
159- //
160- // Packaging services (azd package)
161- //
162- // (✓) Done: Packaging service basketservice
163- // - Package Output: /var/folders/6n/sxbj12js5ksg6ztn0kslqp400000gn/T/azd472091284
164- //
165- // (✓) Done: Packaging service catalogservice
166- // - Package Output: /var/folders/6n/sxbj12js5ksg6ztn0kslqp400000gn/T/azd2265185954
167- //
168- // (✓) Done: Packaging service frontend
169- // - Package Output: /var/folders/6n/sxbj12js5ksg6ztn0kslqp400000gn/T/azd2956031596
170- //
171- // /* cSpell:enable */
172- // Which is nice - since the above is not the package that we publish (instead it's the raw output of
173- // `dotnet publish`, as if you were going to run on App Service.).
174- //
175- // With .NET 8, we'll be able to build just the container image, by setting ContainerArchiveOutputPath
176- // as a property when we run `dotnet publish`. If we set this to the filepath of a tgz (doesn't need to exist)
177- // the the action will just produce a container image and save it to that tgz, as `docker save` would have. It will
178- // not push the container image.
179- //
180- // It's probably right for us to think about "package" for a containerized application as meaning "produce the tgz"
181- // of the image, as would be done by `docker save` and then do this for both DotNetContainerAppTargets and
182- // ContainerAppTargets.
183- if svc .Host == project .DotNetContainerAppTarget {
184- continue
185- }
186151
187- stepMessage := fmt .Sprintf ("Packaging service %s" , svc .Name )
188- pa .console .ShowSpinner (ctx , stepMessage , input .Step )
152+ projectEventArgs := project.ProjectLifecycleEventArgs {
153+ Project : pa .projectConfig ,
154+ }
189155
190- // Skip this service if both cases are true:
191- // 1. The user specified a service name
192- // 2. This service is not the one the user specified
193- if targetServiceName != "" && targetServiceName != svc .Name {
194- pa .console .StopSpinner (ctx , stepMessage , input .StepSkipped )
195- continue
196- }
156+ packageResults := map [string ]* project.ServicePackageResult {}
197157
198- options := & project.PackageOptions {OutputPath : pa .flags .outputPath }
199- packageResult , err := async .RunWithProgress (
200- func (packageProgress project.ServiceProgress ) {
201- progressMessage := fmt .Sprintf ("Packaging service %s (%s)" , svc .Name , packageProgress .Message )
202- pa .console .ShowSpinner (ctx , progressMessage , input .Step )
203- },
204- func (progress * async.Progress [project.ServiceProgress ]) (* project.ServicePackageResult , error ) {
205- return pa .serviceManager .Package (ctx , svc , nil , progress , options )
206- },
207- )
208- pa .console .StopSpinner (ctx , stepMessage , input .GetStepResultFormat (err ))
209-
210- if err != nil {
211- return nil , err
212- }
213- packageResults [svc .Name ] = packageResult
158+ err = pa .projectConfig .Invoke (ctx , project .ProjectEventPackage , projectEventArgs , func () error {
159+ for index , svc := range serviceTable {
160+ // TODO(ellismg): We need to figure out what packaging an containerized dotnet app means. For now, just skip it.
161+ // We "package" the app during deploy when we call `dotnet publish /p:PublishProfile=DefaultContainer` to build
162+ // and push the container image.
163+ //
164+ // Doing this skip here means that during `azd up` we don't show output like:
165+ // /* cSpell:disable */
166+ //
167+ // Packaging services (azd package)
168+ //
169+ // (✓) Done: Packaging service basketservice
170+ // - Package Output: /var/folders/6n/sxbj12js5ksg6ztn0kslqp400000gn/T/azd472091284
171+ //
172+ // (✓) Done: Packaging service catalogservice
173+ // - Package Output: /var/folders/6n/sxbj12js5ksg6ztn0kslqp400000gn/T/azd2265185954
174+ //
175+ // (✓) Done: Packaging service frontend
176+ // - Package Output: /var/folders/6n/sxbj12js5ksg6ztn0kslqp400000gn/T/azd2956031596
177+ //
178+ // /* cSpell:enable */
179+ // Which is nice - since the above is not the package that we publish (instead it's the raw output of
180+ // `dotnet publish`, as if you were going to run on App Service.).
181+ //
182+ // With .NET 8, we'll be able to build just the container image, by setting ContainerArchiveOutputPath
183+ // as a property when we run `dotnet publish`. If we set this to the filepath of a tgz (doesn't need to exist)
184+ // the the action will just produce a container image and save it to that tgz, as `docker save` would have.
185+ // It will not push the container image.
186+ //
187+ // It's probably right for us to think about "package" for a containerized application as meaning
188+ // "produce the tgz" of the image, as would be done by `docker save` and then do this for both
189+ // DotNetContainerAppTargets and ContainerAppTargets.
190+ if svc .Host == project .DotNetContainerAppTarget {
191+ continue
192+ }
193+
194+ stepMessage := fmt .Sprintf ("Packaging service %s" , svc .Name )
195+ pa .console .ShowSpinner (ctx , stepMessage , input .Step )
214196
215- // report package output
216- pa .console .MessageUxItem (ctx , packageResult .Artifacts )
217- if index < serviceCount - 1 {
218- pa .console .Message (ctx , "" )
197+ // Skip this service if both cases are true:
198+ // 1. The user specified a service name
199+ // 2. This service is not the one the user specified
200+ if targetServiceName != "" && targetServiceName != svc .Name {
201+ pa .console .StopSpinner (ctx , stepMessage , input .StepSkipped )
202+ continue
203+ }
204+
205+ options := & project.PackageOptions {OutputPath : pa .flags .outputPath }
206+ packageResult , err := async .RunWithProgress (
207+ func (packageProgress project.ServiceProgress ) {
208+ progressMessage := fmt .Sprintf ("Packaging service %s (%s)" , svc .Name , packageProgress .Message )
209+ pa .console .ShowSpinner (ctx , progressMessage , input .Step )
210+ },
211+ func (progress * async.Progress [project.ServiceProgress ]) (* project.ServicePackageResult , error ) {
212+ return pa .serviceManager .Package (ctx , svc , nil , progress , options )
213+ },
214+ )
215+ pa .console .StopSpinner (ctx , stepMessage , input .GetStepResultFormat (err ))
216+
217+ if err != nil {
218+ return err
219+ }
220+ packageResults [svc .Name ] = packageResult
221+
222+ // report package output
223+ pa .console .MessageUxItem (ctx , packageResult .Artifacts )
224+ if index < serviceCount - 1 {
225+ pa .console .Message (ctx , "" )
226+ }
219227 }
228+
229+ return nil
230+ })
231+
232+ if err != nil {
233+ return nil , err
220234 }
221235
222236 if pa .formatter .Kind () == output .JsonFormat {
0 commit comments