Jika Anda membuat fungsi baru, lihat Panduan Memulai Konsol di Cloud Run. Konten di halaman ini hanya berlaku untuk fungsi lama yang sudah ada yang dibuat dengan Cloud Functions v1 API.
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Menentukan dependensi di .NET
Fungsi .NET Cloud Run menggunakan file project Microsoft Build Engine (MSBuild).
File ini sangat penting dalam proses build dan deployment. Untuk C#, ekstensi filenya adalah .csproj, untuk F#-nya adalah .fsproj, dan
untuk Visual Basic adalah .vbproj.
Misalnya, berikut adalah file .csproj untuk contoh C# Hello World:
Anda dapat menambahkan library ke file project fungsi sebagai berikut:
dotnet add package MY_LIBRARY
Functions Framework adalah dependensi wajib untuk semua fungsi. Meskipun fungsi Cloud Run
menginstalnya untuk Anda saat fungsi tersebut dibuat, sebaiknya
sertakan sebagai dependensi eksplisit agar lebih jelas.
Jika fungsi Anda bergantung pada dependensi pribadi, sebaiknya
cerminkan functions-framework ke registry pribadi Anda. Sertakan functions-framework
yang diduplikasi sebagai dependensi ke fungsi Anda untuk menghindari penginstalan
paket dari internet publik.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-19 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)."]]