Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
La modernización de código para .NET, potenciada por los modelos de IA generativa de Gemini, es una herramienta de generación de código y modernización de aplicaciones. Te ayuda a modernizar tus aplicaciones de Microsoft .NET Framework que dependen de Windows refactorizando tus aplicaciones en código .NET multiplataforma.
Las aplicaciones .NET multiplataforma, a diferencia de las aplicaciones de .NET Framework, se pueden ejecutar en Linux, lo que elimina la necesidad de licencias de Windows y habilita capacidades nativas de la nube, incluida la creación de contenedores.
En esta guía, otorgarás roles de IAM para tu proyecto de Google Cloud, crearás un bucket de Cloud Storage, crearás una clave de la API de Gemini y, luego, instalarás la extensión de code-modernization-for-dotnet en tu máquina local para refactorizar tu aplicación de .NET Framework en código .NET multiplataforma.
Antes de comenzar
Crea una Cuenta de Google si aún no tienes una. Puedes usar cualquier dirección de correo electrónico para crear una Cuenta de Google, incluida tu dirección de correo electrónico laboral.
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.
En VS Code, navega a Extensiones en la barra de actividades.
Haz clic en more_horizVistas y más acciones y selecciona Instalar desde VSIX.
Navega hasta el archivo del paquete VSIX y selecciónalo. Esto inicia la instalación de la extensión Code-modernization-for-dotnet en VS Code en tu máquina local.
Una vez que se complete la instalación, reinicia VS Code.
Actualiza la configuración de Code Modernization for .NET extension de la siguiente manera:
Modo de extensión: LocalGit (experimental)
Project ID (ID del proyecto): PROJECT_ID
Nombre del bucket: BUCKET_NAME
Región: us-central1
Secreto de la API de Gemini: gemini-api-key-secret-name
Cuenta de Google: GOOGLE_ACCOUNT
Framework de destino: .NET 8.0
Reemplaza lo siguiente:
PROJECT_ID: Es el ID de tu proyecto Google Cloud, por ejemplo, 1234567890.
BUCKET_NAME: Es el nombre de tu bucket de Cloud Storage.
GOOGLE_ACCOUNT: Tu Cuenta de Google, por ejemplo, your_full_name@gmail.com
Activa la compilación
Para acceder a Google Cloud, ejecuta el siguiente comando:
gcloud auth login --update-adc
Para activar el flujo de trabajo de modernización, en la barra de actividades, selecciona Control de código fuente, haz clic en more_horizMás acciones para abrir el menú contextual y selecciona Google Cloud: Modernizar código de .NET.
Agrega tu proyecto a la lista de entidades permitidas
Para que tu proyecto se incluya en la lista de entidades permitidas, envía por correo electrónico el ID de tu cuenta de servicio de Cloud Build a code-modernization-for-dotnet-discuss@google.com.
También puedes comunicarte con la misma dirección de correo electrónico para obtener asistencia, hacer preguntas o proporcionar comentarios.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 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."]]