Stay organized with collections
Save and categorize content based on your preferences.
Code modernization for .NET, powered by Gemini Generative AI models, is
a code generation and application modernization tool. It helps you modernize
your Microsoft .NET Framework applications that are Windows-dependent by
refactoring your applications to cross-platform .NET code.
Cross-platform .NET applications, unlike .NET Framework applications, can run on Linux,
eliminating the need for Windows licenses and enabling cloud-native capabilities including containerization.
In this guide, you'll grant IAM roles for your Google Cloud
project, create a Cloud Storage bucket, create a Gemini API
key, and install the code-modernization-for-dotnet extension on your local
machine to re-factor your .NET Framework application to cross-platform .NET
code.
Before you begin
Create a Google
Account, if you don't already have one. You can use any email address to
create a Google Account, including your work email address.
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.
In VS Code, navigate to Extensions in the activity bar.
Click more_horizViews and More
Actions and select Install from VSIX.
Navigate to and select the VSIX package file. This initiates the installation
of the Code-modernization-for-dotnet extension in VS Code on your local
machine.
Once the installation is complete, restart VS Code.
Update Code Modernization for .NET extension settings to the following:
Extension Mode: LocalGit (experimental)
Project ID: PROJECT_ID
Bucket Name: BUCKET_NAME
Region: us-central1
Gemini API Secret: gemini-api-key-secret-name
Google Account: GOOGLE_ACCOUNT
Target Framework: .NET 8.0
Replace the following:
PROJECT_ID: The ID of your Google Cloud
project—for example, 1234567890.
BUCKET_NAME: The name of your
Cloud Storage bucket.
GOOGLE_ACCOUNT: Your Google Account—for example, your_full_name@gmail.com.
Trigger the build
To login to Google Cloud, run the following command:
gcloud auth login --update-adc
To trigger the modernization workflow, in the activity bar, select Source
Control, click more_horizMore Actions
to open the context menu, and select Google Cloud: Modernize .NET code.
Add your project to the allow list
To get your project on the allow list, email your Cloud Build Service Account ID
to code-modernization-for-dotnet-discuss@google.com.
You can also contact the same email address for support, to ask questions, or to
provide feedback.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 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."]]