Reputation: 3685
Can ASP.NET Core apps be deployed via msdeploy.exe and a .pubxml definition similar to what was possible for pre-.NET Core? This is the command that I've used previously:
msbuild myproj.csproj /p:DeployOnBuild=true /p:PublishProfile=<profile-name>
.
If not, what is the preferred way to deploy an ASP.NET Core app from the command line?
Upvotes: 3
Views: 7197
Reputation: 364
To deploy your asp.net core app to Azure web App simply do the following steps:
1. dotnet publishsomeproject.csproj -c release -o someDirectory
2. msdeploy.exe -verb:sync -source:contentPath="someDirectory" -dest:contentPath="webAppName",ComputerName="https://WebAppName.scm.azurewebsites.net/msdeploy.axd",UserName="username",Password="password",IncludeAcls="False",AuthType="Basic"
-enablerule:AppOffline -enableRule:DoNotDeleteRule -retryAttempts:20 -verbose
Username and Password can be retrieved or set on the deployment preview section in the web app in Azure portal. I have set an env path for my msdeploy.exe
which can be found usually here C:\Program Files\IIS\Microsoft Web Deploy V3
.
Upvotes: 4
Reputation: 461
You can find documentation on the commandline usage here : https://github.com/aspnet/websdk/blob/dev/README.md#microsoftnetsdkpublish
You can use any of the below commands to publish using MSDeploy from commandline
msbuild WebApplication.csproj /p:DeployOnBuild=true /p:PublishProfile=<MsDeployProfileName> /p:Password=<DeploymentPassword>
or
dotnet publish WebApplication.csproj /p:PublishProfile=<MsDeployProfileName> /p:Password=<DeploymentPassword>
You can find samples of various profiles here - https://github.com/vijayrkn/PublishProfiles/tree/master/samples
To fix the errors. make sure you run restore first before running the publish command:
dotnet restore
Upvotes: 4
Reputation: 678
One approach using the dotnet
cli tool is the dotnet publish
command.
dotnet restore
dotnet publish -c Release -o output
This will restore all NuGet dependencies and then create a release build in a folder named output
. You can then "xcopy deploy" it, add to a Dockerfile or do whatever else you need to do.
Note that this works with csproj
based projects using newer versions of the dotnet
cli tool (which no longer support project.json
files).
Upvotes: 0