Se stai creando una nuova funzione, consulta la guida rapida della console su Cloud Run. I contenuti di questa pagina si applicano solo alle funzioni legacy esistenti create con l'API Cloud Functions v1.
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Specificare le dipendenze in .NET
Le funzioni Cloud Run .NET utilizzano
file di progetto Microsoft Build Engine (MSBuild).
Questi file sono fondamentali per il processo di compilazione e deployment. Per C# l'estensione del file è .csproj, per F# è .fsproj e per Visual Basic è .vbproj.
Ad esempio, di seguito è riportato il file .csproj per l'esempio Hello World in C#:
Puoi aggiungere librerie al file del progetto della funzione nel seguente modo:
dotnet add package MY_LIBRARY
Functions Framework è una dipendenza obbligatoria per tutte le funzioni. Sebbene le funzioni Cloud Run lo installino per tuo conto al momento della creazione della funzione, ti consigliamo di includerlo come dipendenza esplicita per maggiore chiarezza.
Se la tua funzione si basa su dipendenze private, ti consigliamo di eseguire il mirroring di functions-framework nel tuo registry privato. Includi functions-framework sottoposto a mirroring come dipendenza della funzione per evitare di installare il pacchetto dalla rete internet pubblica.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-03 UTC."],[[["\u003cp\u003e.NET Cloud Run functions utilize MSBuild project files (e.g., \u003ccode\u003e.csproj\u003c/code\u003e, \u003ccode\u003e.fsproj\u003c/code\u003e, \u003ccode\u003e.vbproj\u003c/code\u003e) which are essential for building and deploying functions.\u003c/p\u003e\n"],["\u003cp\u003eLibraries can be added to a function's project file using the \u003ccode\u003edotnet add package MY_LIBRARY\u003c/code\u003e command.\u003c/p\u003e\n"],["\u003cp\u003eThe Functions Framework is a required dependency for all functions, and including it explicitly is recommended for clarity.\u003c/p\u003e\n"],["\u003cp\u003eFor private dependencies, mirroring \u003ccode\u003efunctions-framework\u003c/code\u003e to a private registry and using it as a dependency is recommended to avoid installing from the public internet.\u003c/p\u003e\n"]]],[],null,["# Specify dependencies in .NET\n============================\n\n.NET Cloud Run functions use\n[Microsoft Build Engine (MSBuild) project files](https://docs.microsoft.com/en-us/aspnet/web-forms/overview/deployment/web-deployment-in-the-enterprise/understanding-the-project-file).\nThese files are central to the build and deployment\nprocess. For C# the file extension is `.csproj`, for F# it is `.fsproj`, and\nfor Visual Basic it is `.vbproj`.\n\nFor example, here is the `.csproj` file for the C# Hello World sample: \n\n \u003cProject Sdk=\"Microsoft.NET.Sdk\"\u003e\n \u003cPropertyGroup\u003e\n \u003cOutputType\u003eExe\u003c/OutputType\u003e\n \u003cTargetFramework\u003enet6.0\u003c/TargetFramework\u003e\n \u003c/PropertyGroup\u003e\n\n \u003cItemGroup\u003e\n \u003cPackageReference Include=\"Google.Cloud.Functions.Hosting\" Version=\"2.2.1\" /\u003e\n \u003c/ItemGroup\u003e\n \u003c/Project\u003e\n\nYou can add libraries to your function's project file as follows: \n\n```\ndotnet add package MY_LIBRARY\n```\n\nThe [Functions Framework](/functions/1stgendocs/functions-framework) is a\nrequired dependency for all functions. Although Cloud Run functions\ninstalls it on your behalf when the function is created, we recommend\nthat you include it as an explicit dependency for clarity.\n\nIf your function relies on private dependencies, we recommend that you\nmirror `functions-framework` to your private registry. Include the mirrored\n`functions-framework` as a dependency to your function to avoid installing the\npackage from the public internet.\n\nFor more discussion of dependencies and other types of customization,\nsee [Customization through Functions Startup classes](https://github.com/GoogleCloudPlatform/functions-framework-dotnet/blob/master/docs/customization.md#customization-through-functions-startup-classes)."]]