[Azure Functions] Improve local NuGet build script#8174
[Azure Functions] Improve local NuGet build script#8174lucaspimentel merged 2 commits intomasterfrom
Conversation
There was a problem hiding this comment.
💡 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".
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
| # Remove packages from NuGet cache | ||
| $packagesToRemove = @('Datadog.AzureFunctions', 'Datadog.Serverless.Compat') |
There was a problem hiding this comment.
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 😬
There was a problem hiding this comment.
(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.AzureFunctionspackage and copy nupkg into a local nuget feed - build a sample Azure Functions app that references
Datadog.AzureFunctionsDatadog.AzureFunctionsgoes into nuget's global cache. You're saying I can stop this from happening?
- test app, repeat steps
There was a problem hiding this comment.
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>
## 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.
Summary of changes
Improves the
Build-AzureFunctionsNuget.ps1script with better verbosity control, clearer output, improved error handling, and enhanced NuGet cache cleanup.Reason for change
The script previously had:
Datadog.AzureFunctionsfrom NuGet cache, missingDatadog.Serverless.Compatdotnet restorestep that was sometimes requiredImplementation details
Add missing NuGet restore
dotnet restorestep before building the package to ensure dependencies are resolved. This was step is sometimes required and had to be done manually.Output verbosity
-Verboseparameter support to control verbosity ofdotnetandnukecommands$VerbosePreferenceto appropriate verbosity levels for dotnet (detailed/quiet) and nuke (normal/quiet)Write-Host -ForegroundColor GreenNuGet cache cleanup
Datadog.AzureFunctions,Datadog.Serverless.Compat)Misc
Test coverage
Tested manually.
Other details
🤖 Co-Authored-By: Claude Code