12
votes

From a local machine I can publish a .NET Core application to Azure Web Service as a self-hosted application by defining <SelfContained>true</SelfContained> in publish profile.

App Service Deploy task in Azure DevOps pipeline publishes it to IIS by default. How configure it to publish as self-hosted?

1

1 Answers

15
votes

I got this working in Azure Dev Ops with my Blazor Server Side App that is targeting a preview version of .NET Core 3.0. To do this without creating a yaml file for your build definition you should be able to add the following argument on your dotnet publish task if you're not targeting a preview version of .NET Core.

-r win-x86 --self-contained true

The -r is the run time that you want to target, in my case I selected win-x86 since that is what my app service is configured to use. Then just add the self contained argument. Your full argument will probably look something like this:

--configuration $(BuildConfiguration) -r win-x86 --self-contained true --output $(build.artifactstagingdirectory)

This link covers the dotnet publish command. This is the same command that is executed when you publish from your local machine dotnet publish

The full list of run time identifiers can be found here: run time identfiers

gist of the complete build definition in yaml file yaml