當您正在開發 ASP.NET Core 專案時,您可以自訂檔案 launchSettings.js的內容,以設定專案在開發案例中的啟動方式。When you're developing ASP.NET Core projects, you can configure how your project should be started in development scenarios by customizing the contents of the launchSettings.json file. 在 Visual Studio for Mac 中,您可以使用 [專案選項] UI 或直接編輯此檔案來更新此檔案。In Visual Studio for Mac, you can update this file by using the project options UI or by directly editing it. 當您在 Windows 上執行 Visual Studio 或從命令列執行時,這個檔案就是您可以使用的相同設定檔案 dotnetThis file is the same configuration file that you can use when running Visual Studio on Windows or from the command line through dotnet. 這個檔案會儲存在您的專案的 [Properties] 資料夾底下。This file is stored in your project under the Properties folder.

如需詳細資訊,請參閱 在 ASP.NET Core 中使用多個環境For more detailed info, see Use multiple environments in ASP.NET Core. 在本文中,我們將討論如何在 Visual Studio for Mac 中更新此檔案。In this article, we'll cover how to update this file in Visual Studio for Mac.

使用 Visual Studio for Mac 來更新啟動設定Update the start configuration by using Visual Studio for Mac

您可以直接編輯 Visual Studio for Mac 中的 launchSettings.js,也可以使用專案選項來編輯它。You can directly edit the launchSettings.json file in Visual Studio for Mac, or you can use project options to edit it. 若要取得專案選項,請以滑鼠右鍵按一下您的專案,然後選取 [ 選項]。To get to the project options, right-click your project and select Options.

已選取 [選項] 的專案快捷方式功能表

選取 [執行設定] > Configurations > 預設值Select Run > Configurations > Default.

專案選項中的 [執行]、[設定] 和 [預設值]

主要是在這裡設定兩個專案:Primarily, you'll configure two things here:

  • 環境變數Environment variables
  • 專案的應用程式 URLApp URL for the project

設定環境變數Configure environment variables

您可以使用方格來指定環境變數的值。You can use the grid to specify values for environment variables. 當您在 Visual Studio for Mac 中啟動應用程式時,將會設定這些環境變數。These environment variables will be set when you start your application in Visual Studio for Mac. 當您在開發 ASP.NET Core 的應用程式時,應該留意到特殊的 ASPNETCORE_ENVIRONMENT 環境變數。When you're developing ASP.NET Core applications, you should be aware of the special ASPNETCORE_ENVIRONMENT environment variable. 若要深入瞭解,請參閱 在 ASP.NET Core 中使用多個環境To learn more, see Use multiple environments in ASP.NET Core.

設定起始 URLConfigure the start URL

若要設定將用來啟動應用程式的 URL,請移至 [ ASP.NET Core ] 索引標籤。To configure the URL that the application will be started with, go to the ASP.NET Core tab.

專案選項中的應用程式 URL

您可以在這裡指定應用程式在啟動時要接聽的 URL。Here you can specify the URL that the application will listen on when it's started.