本文档介绍如何设置 Visual Studio 的发布向导,以简化将 .NET 应用部署到 Google Cloud的工作。
简介
借助最新版本的 Cloud Tools for Visual Studio,您可以更轻松地将 .NET 应用部署到 Google Cloud。我们现在在扩展程序中内置了一个部署向导,可将您的应用部署到以下受支持的目标:
Compute Engine:适用于 ASP.NET 4.x 应用
App Engine 柔性环境和 Google Kubernetes Engine:适用于 ASP.NET Core 应用
部署向导将自动检测项目支持的目标,并引导您完成部署过程。
开始使用
要调用部署向导,请依次点击工具 > Google Cloud Tools > 将 [项目名称] 发布到 Google Cloud (Publish [PROJECT-NAME] to Google Cloud),或右键点击“解决方案资源管理器”(Solution Explorer) 中的项目节点,然后点击将 [项目名称] 发布到 Google Cloud (Publish [PROJECT-NAME] to Google Cloud)。
部署向导将显示与所选项目兼容的 Google Cloud 部署目标。
如果要更改项目,请依次点击工具 > Google Cloud Tools > 打开 Cloud Explorer (Open Cloud Explorer) 以打开 Cloud Explorer,然后选择要部署的项目。
部署 ASP.NET 4.x 应用
要在 Compute Engine 上部署 ASP.NET 4.x 应用,请执行以下操作:
依次点击工具 > Google Cloud Tools > 将 [项目名称] 发布到 Google Cloud (Publish [PROJECT-NAME] to Google Cloud),以打开部署向导。
选择 Compute Engine
选择 Windows 虚拟机实例和部署凭据
Windows 虚拟机必须运行 IIS 并能够运行 ASP.NET 4.x 应用(例如从 Deployment Manager 创建的 ASP.NET 虚拟机)。
选择部署凭据。要创建 Windows 凭据,请点击管理凭据。
点击发布以构建应用并将其部署到选定的虚拟机。
Visual Studio 输出窗口中将显示部署进度,并且 Visual Studio shell 状态栏中将显示进度指示器。
部署 ASP.NET Core 应用
ASP.NET Core 应用可以在 Docker 容器内运行,因此您的应用可以部署在 App Engine 柔性环境和 GKE 上。
在 App Engine 柔性环境中部署
要在柔性环境中部署,请执行以下操作:
依次点击工具 > Google Cloud Tools > 将 [项目名称] 发布到 Google Cloud (Publish [PROJECT-NAME] to Google Cloud),以打开部署向导。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[],[],null,["# Visual Studio Deployment Wizard\n\n| **Beta**\n|\n|\n| This feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis document shows you how to set up Visual Studio's Publishing Wizard to\nsimplify deployment of .NET apps to Google Cloud.\n\nIntroduction\n------------\n\nDeploying .NET apps to Google Cloud is easier than ever with the latest release\nof Cloud Tools for Visual Studio. We now have a deployment wizard built into the\nextension that will deploy your app to the following supported targets:\n\n- Compute Engine for ASP.NET 4.x apps\n- App Engine flexible environment and Google Kubernetes Engine for ASP.NET Core apps\n\nThe deployment wizard will automatically detect what targets are supported for\nyour project and guide you through the deployment process.\n\nGetting started\n---------------\n\nThe deployment wizard can be invoked by either going to **Tools** \\\u003e\n**Google Cloud Tools** \\\u003e **Publish \\[PROJECT-NAME\\] to Google Cloud** or by\nright-clicking on the project node in the Solution Explorer and clicking on\n**Publish \\[PROJECT-NAME\\] to Google Cloud**.\n| **Note:** The **Publish \\[PROJECT-NAME\\] to Google Cloud** menu item will only be enabled if the startup project for the solution is compatible with Google Cloud.\n\nThe deployment wizard will display Google Cloud deployments targets that are\ncompatible with the selected project.\n\nIf you want to change the project, open the Cloud Explorer by clicking on\n**Tools** \\\u003e **Google Cloud Tools** \\\u003e **Open Cloud Explorer** and select the\nproject you want to deploy.\n\nDeploying ASP.NET 4.x Apps\n--------------------------\n\n| **Note:** ASP.NET 4.x apps only run on Windows VMs on Compute Engine.\n\nTo deploy your ASP.NET 4.x app on Compute Engine:\n\n1. Open the deployment wizard by clicking **Tools** \\\u003e **Google Cloud Tools** \\\u003e\n **Publish \\[PROJECT-NAME\\] to Google Cloud**.\n\n2. Select **Compute Engine**\n\n3. Select the Windows VM instance and deployment credentials\n\n - The Windows VM has to be running IIS and capable of running ASP.NET 4.x\n apps, such as an ASP.NET VM created from the\n [Deployment\n Manager](https://console.cloud.google.com/marketplace/details/click-to-deploy-images/aspnet?q=asp.net).\n\n - Select credentials for the deployment. To create Windows credentials click\n on **Manage Credentials**.\n\n4. Click **Publish** to build and deploy your app to the selected VM.\n\nDeployment progress will be displayed in the Visual Studio output window and a\nprogress indicator will be displayed in the Visual Studio shell status bar.\n\nDeploying ASP.NET Core Apps\n---------------------------\n\nASP.NET Core apps can run inside of a Docker container so your app can be\ndeployed on the App Engine flexible environment and\nGKE.\n\n### Deploying on App Engine Flexible Environment\n\nTo deploy on flexible environment:\n\n1. Open the deployment wizard by clicking **Tools** \\\u003e **Google Cloud Tools** \\\u003e\n **Publish \\[PROJECT-NAME\\] to Google Cloud**.\n\n2. Select **App Engine Flex**\n\n3. Enter your app's version name and traffic management choice.\n\n - The default version name is based on the current system time. You can specify a different name.\n\n | **Note:** Specifying an existing version name will cause the previous version to be overwritten.\n - **Promoting version** lets you choose if this app version should receive 100% of the traffic. Checking this box will result in the new app receiving all of the traffic immediately after deployment.\n4. Click **Publish** to build and deploy your app to the App Engine\n flexible environment.\n\nThat's it! Your app will be deployed and progress will be displayed in the\nVisual Studio output window.\n\nCustom App Engine settings can be done by creating an `app.yaml` file\nin the root folder of your project.\n\nTo generate `app.yaml`, right click on the project you want to deploy and\nclick **Generate app.yaml and Dockerfile for \\[PROJECT-NAME\\]**. You can delete\nthe Dockerfile if you want to run the default Docker image.\n\n### Deploying on GKE\n\nTo deploy on GKE:\n\n1. Open the deployment wizard by clicking **Tools** \\\u003e **Google Cloud Tools** \\\u003e\n **Publish \\[PROJECT-NAME\\] to Google Cloud**.\n\n2. Select **Container Engine**.\n\n3. Select a cluster for deployment, enter your app's deployment name, version\n and the number of replicas.\n\n - To create a cluster, click **Create new cluster** . This will take you to\n the cluster creation page on Google Cloud console. To view the cluster in\n Visual Studio, click **Refresh clusters**.\n\n - The deployment name is used when creating the Kubernetes deployment and,\n if optionally selected, the kubernetes service to run your app on the\n cluster. You can change the name to something more descriptive.\n\n | **Note:** If you use a name that already exists then the old deployment will be updated instead of creating a new deployment.\n - The default version name is based on the current system time. You can specify a different name.\n\n | **Note:** Specifying an existing version name will cause the previous version to be overwritten.\n - The number of replicas can be changed, the default is three.\n\n - You can choose to expose a Kubernetes service on the Internet. By\n exposing a public service on the Internet you will get a public IP address\n that you can use to access your service from outside your cluster.\n\n4. Click **Publish**\n\nThat's it! Your app will be packaged in a Docker image and deployed to your\ncontainer. If your app is an exposed service then Visual Studio will wait until\nthe service's IP address is available."]]