Skip to content

[Azure Functions] Improve local NuGet build script#8174

Merged
lucaspimentel merged 2 commits intomasterfrom
lpimentel/improve-azure-functions-nuget-build-script
Feb 10, 2026
Merged

[Azure Functions] Improve local NuGet build script#8174
lucaspimentel merged 2 commits intomasterfrom
lpimentel/improve-azure-functions-nuget-build-script

Conversation

@lucaspimentel
Copy link
Member

@lucaspimentel lucaspimentel commented Feb 7, 2026

Summary of changes

Improves the Build-AzureFunctionsNuget.ps1 script with better verbosity control, clearer output, improved error handling, and enhanced NuGet cache cleanup.

Reason for change

The script previously had:

  • Inconsistent verbosity levels and minimal user feedback during execution
  • Only removed Datadog.AzureFunctions from NuGet cache, missing Datadog.Serverless.Compat
  • Missing dotnet restore step that was sometimes required

Implementation details

Add missing NuGet restore

  • Adds explicit dotnet restore step before building the package to ensure dependencies are resolved. This was step is sometimes required and had to be done manually.

Output verbosity

  • Adds -Verbose parameter support to control verbosity of dotnet and nuke commands
  • Maps PowerShell's $VerbosePreference to appropriate verbosity levels for dotnet (detailed/quiet) and nuke (normal/quiet)
  • Improves output messages with color-coded success indicators using Write-Host -ForegroundColor Green
  • Miscellaneous message formatting consistency

NuGet cache cleanup

  • Refactors NuGet cache cleanup to use a loop over a list of packages (Datadog.AzureFunctions, Datadog.Serverless.Compat)
  • Fixes NuGet cache cleanup to report success/failure clearly

Misc

  • Improves error handling when copying the package to destination with proper file existence check

Test coverage

Tested manually.

Other details

🤖 Co-Authored-By: Claude Code

@lucaspimentel lucaspimentel requested a review from a team as a code owner February 7, 2026 00:13
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4e741a2fbe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lucaspimentel lucaspimentel added the AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos label Feb 7, 2026
@lucaspimentel lucaspimentel changed the title Improve Azure Functions NuGet build script [Azure Functions] Improve NuGet build script Feb 7, 2026
@pr-commenter

This comment was marked as off-topic.

@dd-trace-dotnet-ci-bot

This comment was marked as off-topic.

Copy link
Member

@andrewlock andrewlock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yolo

Comment on lines +73 to +74
# Remove packages from NuGet cache
$packagesToRemove = @('Datadog.AzureFunctions', 'Datadog.Serverless.Compat')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yuuuuuk. The "right" thing to do here is to never add them to the global packages cache and to use a local packages cache instead 😬

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I tried posting this comment before our standup, but github was having issues)

The "right" thing to do here is to never add them to the global packages cache

How do I do this? If I build an Azure Function app that references Datadog.AzureFunctions, the package will be saved into the nuget's global cache by default.

The issue I'm trying to get around is this (this is the dev edit/build/test loop)

  • make changes to Datadog.Trace
  • build Datadog.AzureFunctions package and copy nupkg into a local nuget feed
  • build a sample Azure Functions app that references Datadog.AzureFunctions
    • Datadog.AzureFunctions goes into nuget's global cache. You're saying I can stop this from happening?
  • test app, repeat steps

Copy link
Member Author

@lucaspimentel lucaspimentel Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed over zoom. You mean something like nuget's previous behavior where it would download packages to a path inside your solution solution directory instead of a global cache.

I'll merge this for now and will try out a few things and update in a separate PR.

CLI:

dotnet restore --packages <path>

Env var:

NUGET_PACKAGES=<path>

nuget.config file:

<configuration>
  <config>
    <add key="globalPackagesFolder" value="<path>" />
  </config>
</configuration>

@lucaspimentel lucaspimentel enabled auto-merge (squash) February 9, 2026 23:08
@lucaspimentel lucaspimentel merged commit 141636c into master Feb 10, 2026
141 of 142 checks passed
@lucaspimentel lucaspimentel deleted the lpimentel/improve-azure-functions-nuget-build-script branch February 10, 2026 04:38
@github-actions github-actions bot added this to the vNext-v3 milestone Feb 10, 2026
@lucaspimentel lucaspimentel changed the title [Azure Functions] Improve NuGet build script [Azure Functions] Improve local NuGet build script Feb 10, 2026
@lucaspimentel lucaspimentel added the area:builds project files, build scripts, pipelines, versioning, releases, packages label Feb 10, 2026
lucaspimentel added a commit that referenced this pull request Feb 13, 2026
## Summary of changes

- Use separate Nuke verbosity levels for download (`quiet`) vs build
(`normal`) targets
- Skip building `net461` in local dev script (commented out)
- Disable `CheckEolTargetFramework` warning

## Reason for change
After #8174 changed default verbosity to `quiet`, the package path
output was suppressed, making it harder to locate the generated `.nupkg`
file during local development.

## Implementation details

In `tracer/tools/Build-AzureFunctionsNuget.ps1`, split `$nukeVerbosity`
into two variables:
- `$nukeVerbosityDownload`: `verbose`/`quiet` for
`DownloadBundleNugetFromBuild`
- `$nukeVerbosityBuild`: `verbose`/`normal` for
`BuildAzureFunctionsNuget` (shows package path)

In `tracer/src/Datadog.AzureFunctions/Datadog.AzureFunctions.csproj`,
remove`CheckEolTargetFramework` so we inherit `false` from a parent
directory.

## Test coverage
Manually tested.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos area:builds project files, build scripts, pipelines, versioning, releases, packages area:serverless

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants