You can use the Publish tool to import publish settings and then deploy your app directly out of Visual Studio.
These steps apply to ASP.NET, ASP.NET Core, and .NET Core apps in Visual Studio.
In this tutorial, you will:
- Configure IIS so that you can generate a publish settings file
- Create a publish settings file
- Import the publish settings file into Visual Studio
- Deploy the app to IIS
A publish settings file (.publishsettings) is different than a publishing profile (.pubxml) created in Visual Studio. A publish settings file is created by IIS (or Azure App Service), or it can be manually created, and then it can be imported into Visual Studio.
Note: If you just need to copy a Visual Studio publishing profile (*.pubxml file) from one installation of Visual Studio to another, you can find the publishing profile, .pubxml, in the \\Properties\PublishProfiles folder for managed project types. For websites, look under the \App_Data folder. The publishing profiles are MSBuild XML files.
Configure IIS so that you can generate a publish settings file
Make sure IIS Management Scripts and Tools is installed
Get-WindowsFeature -Name Web-Scripting-Tools
Available means -> it is NOT installed.. so If not installed, install it using:
Add-WindowsFeature -Name Web-Scripting-Tools
Make sure the Windows Optional Feature IIS-ManagementService is installed.
Query for it:
Get-WindowsOptionalFeature -Online -FeatureName IIS-ManagementService | select FeatureName, State
If it’s not enabled, Enable it using:
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ManagementService
Check and make sure Web Deployment Agent Service exists and is running
This part is crucial!
If you should follow this article: https://docs.microsoft.com/en-us/visualstudio/deployment/tutorial-import-publish-settings-iis?view=vs-2019 you’ll most probably end up missing the Configure Web Deploy Publishing. Of course they mention a Service called Web Deployment Agent Service or MsDepSvc as an optional step to check:
(Optional) Verify that Web Deploy is running correctly by opening Control Panel > System and Security > Administrative Tools > Services and make sure that Web Deployment Agent Service is running (the service name is different in older versions).
If the agent service is not running, start it. If it is not present at all, go to Control Panel > Programs > Uninstall a program, find Microsoft Web Deploy . Choose to Change the installation and make sure that you choose Will be installed to the local hard drive for the Web Deploy components. Complete the change installation steps.
In my case – and i’m on a Windows Server 2019 Standard with Visual Studio 2019 Community Edition (Setup – next – next – finish) with the following Visual Studio Installer Workloads:
– ASP.NET and web development
– .NET desktop development
This service didn’t exist.
Googleing and complaining about the bad documentation i found this stack overflow question/answer
For me the reinstall of Web Deploy didn’t work. But I fixed it.
Go into the Server Manager, Roles, click on IIS, click on Add Role Services, check the Management Service. Close that out. Reopen IIS Manager, and voila the option is available!
For Windows2012 R2 server, options is in’Web Server (IIS)’ -> ‘Management Tools’ –> ‘Management Service’
P.S. Some additional steps could be required, as of @Gaui experience. Afterwards go to Programs and Features, find Web Deploy, click Change and check/install all checkboxes/features.
So make sure:
– IIS-ManagementService feature is installed
– AND modify the existing Web Deploy 4.0 Installation which comes as part of one of the two selected Visual Studio 2019 Workloads
Modifying Web Deploy Installation -> AppWiz.cpl:
Now check if you have an installed and running server called Web Deployment Agent Service (MsDepSvc)
(Honestly i’m still not 100% sure if this service is required in order to get the context menu enty Deploy…. Feel free to comment if you find out something interesting )
PS C:\Users\Administrator> Get-Service MsDepSvc Status Name DisplayName ------ ---- ----------- Running MsDepSvc Web Deployment Agent Service