Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Code Modernization for .NET basiert auf Gemini-Modellen für generative KI und ist ein Tool zur Codegenerierung und Anwendungsmodernisierung. Damit können Sie Ihre Windows-abhängigen Microsoft .NET Framework-Anwendungen modernisieren, indem Sie Ihre Anwendungen in plattformübergreifenden .NET-Code umgestalten.
Plattformübergreifende .NET-Anwendungen können im Gegensatz zu .NET Framework-Anwendungen unter Linux ausgeführt werden. Dadurch sind keine Windows-Lizenzen mehr erforderlich und cloudnative Funktionen wie die Containerisierung werden ermöglicht.
In dieser Anleitung weisen Sie IAM-Rollen für Ihr Google Cloud-Projekt zu, erstellen einen Cloud Storage-Bucket, erstellen einen Gemini API-Schlüssel und installieren die code-modernization-for-dotnet-Erweiterung auf Ihrem lokalen Computer, um Ihre .NET Framework-Anwendung in plattformübergreifenden .NET-Code umzugestalten.
Hinweise
Erstellen Sie ein Google-Konto, falls Sie noch keines haben. Sie können eine beliebige E‑Mail-Adresse verwenden, um ein Google-Konto zu erstellen, auch Ihre geschäftliche E‑Mail-Adresse.
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
Rufen Sie in VS Code in der Aktivitätsleiste Erweiterungen auf.
Klicken Sie auf das more_horizAnsichten und weitere Aktionen und wählen Sie Über VSIX installieren aus.
Suchen Sie die VSIX-Paketdatei und wählen Sie sie aus. Dadurch wird die Installation der Code-modernization-for-dotnet-Erweiterung in VS Code auf Ihrem lokalen Computer gestartet.
Starten Sie VS Code nach Abschluss der Installation neu.
Aktualisieren Sie die Code Modernization for .NET extension-Einstellungen auf Folgendes:
Erweiterungsmodus: LocalGit (experimental)
Project ID:PROJECT_ID
Bucket-Name: BUCKET_NAME
Region:us-central1
Gemini API-Secret: gemini-api-key-secret-name
Google-Konto: GOOGLE_ACCOUNT
Zielframework: .NET 8.0
Ersetzen Sie Folgendes:
PROJECT_ID: Die ID Ihres Google Cloud-Projekts, z. B. 1234567890.
BUCKET_NAME: Der Name Ihres Cloud Storage-Bucket.
GOOGLE_ACCOUNT: Ihr Google-Konto, z. B. your_full_name@gmail.com.
Build auslösen
Führen Sie den folgenden Befehl aus, um sich in Google Cloudanzumelden:
gcloud auth login --update-adc
Wenn Sie den Modernisierungs-Workflow auslösen möchten, wählen Sie in der Aktivitätsleiste Quellcodeverwaltung aus, klicken Sie auf more_horizWeitere Aktionen, um das Kontextmenü zu öffnen, und wählen Sie Google Cloud: .NET-Code modernisieren aus.
Projekt auf die Zulassungsliste setzen
Wenn Sie Ihr Projekt auf die Zulassungsliste setzen lassen möchten, senden Sie eine E-Mail mit der ID Ihres Cloud Build-Dienstkontos an code-modernization-for-dotnet-discuss@google.com.
Sie können sich auch unter derselben E‑Mail-Adresse an den Support wenden, um Fragen zu stellen oder Feedback zu geben.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-05 (UTC)."],[],[],null,["# Modernize your .NET application\n\n\u003cbr /\u003e\n\nCode modernization for .NET, powered by Gemini Generative AI models, is\na code generation and application modernization tool. It helps you modernize\nyour Microsoft .NET Framework applications that are Windows-dependent by\nrefactoring your applications to cross-platform .NET code.\n\nCross-platform .NET applications, unlike .NET Framework applications, can run on Linux,\neliminating the need for Windows licenses and enabling cloud-native capabilities including containerization.\n\nIn this guide, you'll grant IAM roles for your Google Cloud\nproject, create a Cloud Storage bucket, create a Gemini API\nkey, and install the `code-modernization-for-dotnet` extension on your local\nmachine to re-factor your .NET Framework application to cross-platform .NET\ncode.\n\nBefore you begin\n----------------\n\n1. [Create a Google\n Account](https://support.google.com/accounts/answer/27441), if you don't already have one. You can use any email address to create a Google Account, including your work email address.\n2. Submit the [Code Modernization for\n .NET: Allowlist Request form](https://docs.google.com/forms/d/1KPLECo92gZ8Q36L1h6EyVpmKr_QieOl6QFROrLOBvd4/edit) to join the allow list. You can't proceed with the steps on this page until this request has been approved.\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Cloud Build, Secret Manager,\n Cloud Storage JSON API, Generative Language API, Cloud Logging,\n and Compute Engine APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=cloudbuild.googleapis.com,secretmanager.googleapis.com,storage-api.googleapis.com,generativelanguage.googleapis.com,logging.googleapis.com,compute.googleapis.com)\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Cloud Build, Secret Manager,\n Cloud Storage JSON API, Generative Language API, Cloud Logging,\n and Compute Engine APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=cloudbuild.googleapis.com,secretmanager.googleapis.com,storage-api.googleapis.com,generativelanguage.googleapis.com,logging.googleapis.com,compute.googleapis.com)\n\n3. [Install VS Code](https://code.visualstudio.com/), if you haven't already.\n\nGrant Identity and Access Management (IAM) roles\n------------------------------------------------\n\n### Console\n\n1. To grant the IAM roles for your Google Cloud project,\n go to the **IAM \\& Admin** page.\n\n [Go to IAM \\& Admin](https://console.cloud.google.com/projectselector/iam-admin/iam?supportedpurview=)\n2. Add the following IAM roles:\n\n- **User Permissions**\n\n - Storage Object User (`roles/storage.objectUser`)\n - Cloud Build Editor (`roles/cloudbuild.builds.editor`)\n- **Cloud Build Service Account**\n\n - Cloud Build Service Account (`roles/cloudbuild.builds.builder`)\n - Secret Manager Viewer (`roles/secretmanager.viewer`)\n - Logs Writer (`roles/logging.logWriter`)\n - Storage Object User (`roles/storage.objectUser`)\n\n### gcloud\n\nTo add the required IAM roles, run the following `gcloud`\ncommands:\n\n- Assign the Storage Object User (`roles/storage.objectUser`) role:\n\n gcloud projects add-iam-policy-binding \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e \\\n --member=\"user:\u003cvar translate=\"no\"\u003eUSER_ID\u003c/var\u003e\" \\\n --role=\"roles/storage.objectUser\"\n\n- Assign the Cloud Build Editor (`roles/cloudbuild.builds.editor`) role:\n\n gcloud projects add-iam-policy-binding \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e \\\n --member=\"user:\u003cvar translate=\"no\"\u003eUSER_ID\u003c/var\u003e\" \\\n --role=\"roles/cloudbuild.builds.editor\"\n\n- Assign the Cloud Build Service Account (`roles/cloudbuild.builds.builder`)\n role:\n\n gcloud projects add-iam-policy-binding \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e \\\n --member=\"serviceAccount:\u003cvar translate=\"no\"\u003eSERVICE_ACCOUNT\u003c/var\u003e\" \\\n --role=\"roles/cloudbuild.builds.builder\"\n\n- Assign the Secret Manager Accessor (`roles/secretmanager.secretAccessor`)\n role:\n\n gcloud projects add-iam-policy-binding \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e \\\n --member=\"serviceAccount:\u003cvar translate=\"no\"\u003eSERVICE_ACCOUNT\u003c/var\u003e\" \\\n --role=\"roles/secretmanager.secretAccessor\"\n\n- Assign the Logs Writer (`roles/logging.logWriter`) role:\n\n gcloud projects add-iam-policy-binding \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e \\\n --member=\"serviceAccount:\u003cvar translate=\"no\"\u003eSERVICE_ACCOUNT\u003c/var\u003e\" \\\n --role=\"roles/logging.logWriter\"\n\n- Assign the Storage Object User (`roles/storage.objectUser`) role:\n\n gcloud projects add-iam-policy-binding \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e \\\n --member=\"serviceAccount:\u003cvar translate=\"no\"\u003eSERVICE_ACCOUNT\u003c/var\u003e\" \\\n --role=\"roles/storage.objectUser\"\n\nCreate a Cloud Storage bucket\n-----------------------------\n\nTo create a Cloud Storage bucket, run the following: \n\n gcloud storage buckets create gs://\u003cvar translate=\"no\"\u003eBUCKET_NAME\u003c/var\u003e \\\n --project=\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\n\nCreate Gemini API key and save in Secret Manager\n------------------------------------------------\n\nTo create a Gemini API key, run the following: \n\n gcloud services api-keys create --project=\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e \\\n --display-name=\"API Key for .Net Modernization\" \\\n --api-target=\"service=generativelanguage.googleapis.com\" \\\n --key-id=\"gemini-api-key\"\n\nTo save the Gemini API key in Secret Manager, run\nthe following: \n\n echo -n \"(gcloud services api-keys get-key-string gemini-api-key \\\n --project=\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e \\\n --format=\"value(keyString)\")\" | \\\n\n gcloud secrets create \"gemini-api-key\" \\\n --project=\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e \\\n --data-file=- \\\n --replication-policy=\"automatic\"\n\nInstall and configure the extension\n-----------------------------------\n\n| **Note:** After submitting the [Code Modernization for\n| .NET: Allowlist Request form](https://docs.google.com/forms/d/1KPLECo92gZ8Q36L1h6EyVpmKr_QieOl6QFROrLOBvd4/edit) to join the allow list, you'll need to wait for the request to be approved before proceeding with the steps in this section.\n\nOnce your [Code Modernization for\n.NET: Allowlist Request form](https://docs.google.com/forms/d/1KPLECo92gZ8Q36L1h6EyVpmKr_QieOl6QFROrLOBvd4/edit) is approved, you'll receive the extension as a\n`.VSIX` file. To install the extension to your local machine, follow these\nsteps:\n\n1. In VS Code, navigate to **Extensions** in the activity bar.\n\n2. Click more_horiz **Views and More\n Actions** and select **Install from VSIX**.\n\n3. Navigate to and select the VSIX package file. This initiates the installation\n of the `Code-modernization-for-dotnet` extension in VS Code on your local\n machine.\n\n4. Once the installation is complete, restart VS Code.\n\n5. Update `Code Modernization for .NET extension` settings to the following:\n\n - **Extension Mode** : `LocalGit (experimental)`\n - **Project ID** : \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\n - **Bucket Name** : \u003cvar translate=\"no\"\u003eBUCKET_NAME\u003c/var\u003e\n - **Region** : `us-central1`\n - **Gemini API Secret** : `gemini-api-key-secret-name`\n - **Google Account** : \u003cvar translate=\"no\"\u003eGOOGLE_ACCOUNT\u003c/var\u003e\n - **Target Framework** : `.NET 8.0`\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: The ID of your Google Cloud project---for example, `1234567890`.\n - \u003cvar translate=\"no\"\u003eBUCKET_NAME\u003c/var\u003e: The name of your Cloud Storage bucket.\n - \u003cvar translate=\"no\"\u003eGOOGLE_ACCOUNT\u003c/var\u003e: Your Google Account---for example, `your_full_name@gmail.com`.\n\nTrigger the build\n-----------------\n\n1. To login to Google Cloud, run the following command:\n\n gcloud auth login --update-adc\n\n2. To trigger the modernization workflow, in the activity bar, select **Source\n Control** , click more_horiz **More Actions**\n to open the context menu, and select **Google Cloud: Modernize .NET code**.\n\nAdd your project to the allow list\n----------------------------------\n\nTo get your project on the allow list, email your Cloud Build Service Account ID\nto `code-modernization-for-dotnet-discuss@google.com`.\n\nYou can also contact the same email address for support, to ask questions, or to\nprovide feedback."]]