From e4fe7e3405e30b1b65c1bf01e2df6e92ee68d0e1 Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Mon, 10 Dec 2018 17:16:26 -0600 Subject: [PATCH] Publish profiles enhancements + cross-links (#9871) --- .../azure-apps/azure-continuous-deployment.md | 3 +- aspnetcore/host-and-deploy/index.md | 8 +- .../visual-studio-publish-profiles.md | 117 ++++++++---------- .../publish-to-azure-webapp-using-vs.md | 3 +- 4 files changed, 62 insertions(+), 69 deletions(-) diff --git a/aspnetcore/host-and-deploy/azure-apps/azure-continuous-deployment.md b/aspnetcore/host-and-deploy/azure-apps/azure-continuous-deployment.md index 3767dc324e..8994cac58e 100644 --- a/aspnetcore/host-and-deploy/azure-apps/azure-continuous-deployment.md +++ b/aspnetcore/host-and-deploy/azure-apps/azure-continuous-deployment.md @@ -4,7 +4,7 @@ author: rick-anderson description: Learn how to create an ASP.NET Core web app using Visual Studio and deploy it to Azure App Service using Git for continuous deployment. ms.author: riande ms.custom: mvc -ms.date: 10/14/2016 +ms.date: 12/06/2018 uid: host-and-deploy/azure-apps/azure-continuous-deployment --- # Continuous deployment to Azure with Visual Studio and Git with ASP.NET Core @@ -224,3 +224,4 @@ View the updated web app by selecting **Browse** from the web app blade in the A * [Create your first pipeline with Azure Pipelines](/azure/devops/pipelines/get-started-yaml) * [Project Kudu](https://github.com/projectkudu/kudu/wiki) +* diff --git a/aspnetcore/host-and-deploy/index.md b/aspnetcore/host-and-deploy/index.md index 7b3b3aa221..fec4fef9ac 100644 --- a/aspnetcore/host-and-deploy/index.md +++ b/aspnetcore/host-and-deploy/index.md @@ -4,7 +4,7 @@ author: guardrex description: Learn how to set up hosting environments and deploy ASP.NET Core apps. ms.author: riande ms.custom: mvc -ms.date: 12/01/2018 +ms.date: 12/06/2018 uid: host-and-deploy/index --- # Host and deploy ASP.NET Core @@ -66,7 +66,11 @@ By using [the Publish Web feature](xref:tutorials/publish-to-azure-webapp-using- ## Publish to Azure -See for instructions on how to publish an app to Azure using Visual Studio. The app can also be published to Azure from the [command line](/azure/app-service/app-service-web-get-started-dotnet). +See for instructions on how to publish an app to Azure using Visual Studio. An additional example is provided by [Create an ASP.NET Core web app in Azure](/azure/app-service/app-service-web-get-started-dotnet). + +## Publish with MSDeploy on Windows + +See for instructions on how to publish an app with a Visual Studio publish profile, including from a Windows command prompt using the [dotnet msbuild](/dotnet/core/tools/dotnet-msbuild) command. ## Host in a web farm diff --git a/aspnetcore/host-and-deploy/visual-studio-publish-profiles.md b/aspnetcore/host-and-deploy/visual-studio-publish-profiles.md index 46a0459328..9199ecd6b3 100644 --- a/aspnetcore/host-and-deploy/visual-studio-publish-profiles.md +++ b/aspnetcore/host-and-deploy/visual-studio-publish-profiles.md @@ -4,24 +4,30 @@ author: rick-anderson description: Learn how to create publish profiles in Visual Studio and use them for managing ASP.NET Core app deployments to various targets. ms.author: riande ms.custom: mvc -ms.date: 10/24/2018 +ms.date: 12/06/2018 uid: host-and-deploy/visual-studio-publish-profiles --- # Visual Studio publish profiles for ASP.NET Core app deployment By [Sayed Ibrahim Hashimi](https://github.com/sayedihashimi) and [Rick Anderson](https://twitter.com/RickAndMSFT) -This document focuses on using Visual Studio 2017 to create and use publish profiles. The publish profiles created with Visual Studio can be run from MSBuild and Visual Studio 2017. See [Publish an ASP.NET Core web app to Azure App Service using Visual Studio](xref:tutorials/publish-to-azure-webapp-using-vs) for instructions on publishing to Azure. +::: moniker range="<= aspnetcore-1.1" + +For the 1.1 version of this topic, download [Visual Studio publish profiles for ASP.NET Core app deployment (version 1.1, PDF)](https://webpifeed.blob.core.windows.net/webpifeed/Partners/VS_Publish_Profiles_1.1.pdf). + +::: moniker-end + +This document focuses on using Visual Studio 2017 or later to create and use publish profiles. The publish profiles created with Visual Studio can be run from MSBuild and Visual Studio. See [Publish an ASP.NET Core web app to Azure App Service using Visual Studio](xref:tutorials/publish-to-azure-webapp-using-vs) for instructions on publishing to Azure. The following project file was created with the command `dotnet new mvc`: -::: moniker range=">= aspnetcore-2.1" +::: moniker range=">= aspnetcore-2.2" ```xml - netcoreapp2.1 + netcoreapp2.2 @@ -33,37 +39,17 @@ The following project file was created with the command `dotnet new mvc`: ::: moniker-end -::: moniker range="= aspnetcore-2.0" +::: moniker range="< aspnetcore-2.2" ```xml - netcoreapp2.0 + netcoreapp2.1 - - - - -``` - -::: moniker-end - -::: moniker range="< aspnetcore-2.0" - -```xml - - - - netcoreapp1.1 - - - - - - + @@ -124,25 +110,11 @@ dotnet publish C:\Webs\Web1 Run the following commands to create and publish a web app: -::: moniker range=">= aspnetcore-2.0" - ```console dotnet new mvc dotnet publish ``` -::: moniker-end - -::: moniker range="< aspnetcore-2.0" - -```console -dotnet new mvc -dotnet restore -dotnet publish -``` - -::: moniker-end - The [dotnet publish](/dotnet/core/tools/dotnet-publish) command produces output similar to the following: ```console @@ -168,7 +140,7 @@ The [dotnet publish](/dotnet/core/tools/dotnet-publish) command calls MSBuild, w MSBuild properties can be passed using either of the following formats: -* ` p:=` +* `p:=` * `/p:=` The following command publishes a `Release` build to a network share: @@ -181,12 +153,12 @@ Confirm that the published app for deployment isn't running. Files in the *publi ## Publish profiles -This section uses Visual Studio 2017 to create a publishing profile. Once created, publishing from Visual Studio or the command line is available. +This section uses Visual Studio 2017 or later to create a publishing profile. Once the profile is created, publishing from Visual Studio or the command line is available. Publish profiles can simplify the publishing process, and any number of profiles can exist. Create a publish profile in Visual Studio by choosing one of the following paths: * Right-click the project in Solution Explorer and select **Publish**. -* Select **Publish <project_name>** from the **Build** menu. +* Select **Publish {PROJECT NAME}** from the **Build** menu. The **Publish** tab of the app capacities page is displayed. If the project lacks a publish profile, the following page is displayed: @@ -208,11 +180,11 @@ The Publish wizard supports the following publish targets: For more information, see [What publishing options are right for me](/visualstudio/ide/not-in-toc/web-publish-options). -When creating a publish profile with Visual Studio, a *Properties/PublishProfiles/<profile_name>.pubxml* MSBuild file is created. The *.pubxml* file is a MSBuild file and contains publish configuration settings. This file can be changed to customize the build and publish process. This file is read by the publishing process. `` is special because it's a global property and shouldn't be in any file that's imported in the build. See [MSBuild: how to set the configuration property](http://sedodream.com/2012/10/27/MSBuildHowToSetTheConfigurationProperty.aspx) for more information. +When creating a publish profile with Visual Studio, a *Properties/PublishProfiles/{PROFILE NAME}.pubxml* MSBuild file is created. The *.pubxml* file is a MSBuild file and contains publish configuration settings. This file can be changed to customize the build and publish process. This file is read by the publishing process. `` is special because it's a global property and shouldn't be in any file that's imported in the build. See [MSBuild: how to set the configuration property](http://sedodream.com/2012/10/27/MSBuildHowToSetTheConfigurationProperty.aspx) for more information. When publishing to an Azure target, the *.pubxml* file contains your Azure subscription identifier. With that target type, adding this file to source control is discouraged. When publishing to a non-Azure target, it's safe to check in the *.pubxml* file. -Sensitive information (like the publish password) is encrypted on a per user/machine level. It's stored in the *Properties/PublishProfiles/<profile_name>.pubxml.user* file. Because this file can store sensitive information, it shouldn't be checked into source control. +Sensitive information (like the publish password) is encrypted on a per user/machine level. It's stored in the *Properties/PublishProfiles/{PROFILE NAME}.pubxml.user* file. Because this file can store sensitive information, it shouldn't be checked into source control. For an overview of how to publish a web app on ASP.NET Core, see [Host and deploy](xref:host-and-deploy/index). The MSBuild tasks and targets necessary to publish an ASP.NET Core app are open-source at https://github.com/aspnet/websdk. @@ -264,7 +236,7 @@ dotnet publish /p:PublishProfile=Azure /p:Configuration=Release Set the following MSBuild properties when using a publish profile: * `DeployOnBuild=true` -* `PublishProfile=` +* `PublishProfile={PUBLISH PROFILE}` When publishing with a profile named *FolderProfile*, either of the commands below can be executed: @@ -315,35 +287,50 @@ msbuild /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=FolderP ## Publish to an MSDeploy endpoint from the command line -Publishing can be accomplished using the .NET Core CLI or MSBuild. `dotnet publish` runs in the context of .NET Core. The `msbuild` command requires .NET Framework, which limits it to Windows environments. +The following example uses an ASP.NET Core web app created by Visual Studio named *AzureWebApp*. An Azure Apps publish profile is added with Visual Studio. For more information on how to create a profile, see the [Publish profiles](#publish-profiles) section. -The easiest way to publish with MSDeploy is to first create a publish profile in Visual Studio 2017 and use the profile from the command line. +To deploy the app using a publish profile, execute the `msbuild` command from a Visual Studio **Developer Command Prompt**. The command prompt is available in the *Visual Studio* folder of the **Start** menu on the Windows taskbar. For easier access, you can add the command prompt to the **Tools** menu in Visual Studio. For more information, see [Developer Command Prompt for Visual Studio](/dotnet/framework/tools/developer-command-prompt-for-vs#run-the-command-prompt-from-inside-visual-studio). -In the following sample, an ASP.NET Core web app is created (using `dotnet new mvc`), and an Azure publish profile is added with Visual Studio. - -Run `msbuild` from a **Developer Command Prompt for VS 2017**. The Developer Command Prompt has the correct *msbuild.exe* in its path with some MSBuild variables set. - -MSBuild uses the following syntax: +MSBuild uses the following command syntax: ```console -msbuild /p:DeployOnBuild=true /p:PublishProfile= /p:Username= /p:Password= +msbuild {PATH} + /p:DeployOnBuild=true + /p:PublishProfile={PROFILE} + /p:Username={USERNAME} + /p:Password={PASSWORD} ``` -Get the `Password` from the *\.PublishSettings* file. Download the *.PublishSettings* file from either: +* {PATH} – Path to the app's project file. +* {PROFILE} – Name of the publish profile. +* {USERNAME} – MSDeploy username. The {USERNAME} can be found in the publish profile. +* {PASSWORD} – MSDeploy password. Obtain the {PASSWORD} from the *{PROFILE}.PublishSettings* file. Download the *.PublishSettings* file from either: + * Solution Explorer: Select **View** > **Cloud Explorer**. Connect with your Azure subscription. Open **App Services**. Right-click the app. Select **Download Publish Profile**. + * Azure portal: Select **Get publish profile** in the web app's **Overview** panel. -* Solution Explorer: Right-click on the Web App and select **Download Publish Profile**. -* Azure portal: Click **Get publish profile** on the Web App's **Overview** panel. - -`Username` can be found in the publish profile. - -The following sample uses the *Web11112 - Web Deploy* publish profile: +The following example uses a publish profile named *AzureWebApp - Web Deploy*: ```console -msbuild "C:\Webs\Web1\Web1.csproj" /p:DeployOnBuild=true - /p:PublishProfile="Web11112 - Web Deploy" /p:Username="$Web11112" - /p:Password="" +msbuild "AzureWebApp.csproj" + /p:DeployOnBuild=true + /p:PublishProfile="AzureWebApp - Web Deploy" + /p:Username="$AzureWebApp" + /p:Password=".........." ``` +A publish profile can also be used with the .NET Core CLI [dotnet msbuild](/dotnet/core/tools/dotnet-msbuild) command from a Windows command prompt: + +```console +dotnet msbuild "AzureWebApp.csproj" + /p:DeployOnBuild=true + /p:PublishProfile="AzureWebApp - Web Deploy" + /p:Username="$AzureWebApp" + /p:Password=".........." +``` + +> [!NOTE] +> The [dotnet msbuild](/dotnet/core/tools/dotnet-msbuild) command is available cross-platform and can compile ASP.NET Core apps on macOS and Linux. However, MSBuild on macOS and Linux isn't capable of deploying an app to Azure or other MSDeploy endpoint. MSDeploy is only available on Windows. + ## Exclude files When publishing ASP.NET Core web apps, the build artifacts and contents of the *wwwroot* folder are included. `msbuild` supports [globbing patterns](https://gruntjs.com/configuring-tasks#globbing-patterns). For example, the following `` element excludes all text (*.txt*) files from the *wwwroot/content* folder and all its subfolders. diff --git a/aspnetcore/tutorials/publish-to-azure-webapp-using-vs.md b/aspnetcore/tutorials/publish-to-azure-webapp-using-vs.md index 049f65bba4..858ebd3c27 100644 --- a/aspnetcore/tutorials/publish-to-azure-webapp-using-vs.md +++ b/aspnetcore/tutorials/publish-to-azure-webapp-using-vs.md @@ -4,7 +4,7 @@ author: rick-anderson description: Learn how to publish an ASP.NET Core app to Azure App Service using Visual Studio. ms.author: riande ms.custom: mvc -ms.date: 10/24/2018 +ms.date: 12/06/2018 uid: tutorials/publish-to-azure-webapp-using-vs --- # Publish an ASP.NET Core app to Azure with Visual Studio @@ -182,4 +182,5 @@ When you have finished testing the app, go to the [Azure portal](https://portal. * [Azure App Service](/azure/app-service/app-service-web-overview) * [Azure resource groups](/azure/azure-resource-manager/resource-group-overview#resource-groups) * [Azure SQL Database](/azure/sql-database/) +* *