Publishing ASP.Net Core app to Azure silently fails in command line

风流意气都作罢 提交于 2019-12-25 16:46:25

问题


I'm trying to publish a dotnet core app to Azure. I've created a publish profile and using visual studio it all works fine. But since I'd like to setup continuous deployment I need to run the deployment using command line.

The official documentation was pretty helpful in identifying that the [ProfileName].ps1 is the best plan of attack.

However it gives no clues on how to use it. First I ran it without parameters and got this error:

Production-publish.ps1 : The term 'Production-publish.ps1' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:1 char:1
+ Production-publish.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Production-publish.ps1:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Next I added the needed parameters:

.\Production-publish -packOutput 'C:\code\my-dotnetcore-proj\publish' -pubProfilePath 'Production.pubxml'

Which ran without error but didn't do ANYTHING!

How can I make the Azure depoyment via Powershell work?


回答1:


After debugging through the publish-module.psm1 to figure out why nothing was getting deployed I noticed that the command is required to supply more parameters. This is how:

.\Production-publish -packOutput 'C:\code\my-dotnetcore-proj\publish' -pubProfilePath 'Production.pubxml' -publishProperties @{
    'username' = '%PublishProfile.Username%'
    'Password' = '%PublishProfile.Password%'
    'AllowUntrustedCertificate' = false
    'AuthType' = 'Basic'}

You obviously have to replace %PublishProfile.Username% and %PublishProfile.Password% and possibly modify Production-publish and Production.pubxml

Note that only the Password parameter is required (considering that the UserName is provided in your .pubxml file)

I actually ended up writing blog article on how to compile and deploy asp.net core sites with TeamCity: How to deploy ASP.NET Core sites using Teamcity to Azure/IIS … or just command line



来源:https://stackoverflow.com/questions/40370128/publishing-asp-net-core-app-to-azure-silently-fails-in-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!