在命令行

时间:2016-11-01 23:22:05

标签: asp.net asp.net-core azure-web-sites web-deployment continuous-deployment

我正在尝试向Azure发布一个dotnet核心应用。我创建了一个发布配置文件并使用visual studio它一切正常。但由于我想设置持续部署,我需要使用命令行运行部署。

official documentation非常有助于确定[ProfileName].ps1是最佳攻击计划。

然而,它没有提供如何使用它的线索。 首先我没有参数运行它并得到了这个错误:

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

接下来我添加了所需的参数:

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

哪个没有错误但是没有做任何事情!

如何通过Powershell工作来实现Azure depoyment?

1 个答案:

答案 0 :(得分:0)

通过publish-module.psm1调试后找出为什么没有部署,我注意到该命令需要提供更多参数。这是如何:

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

您显然必须替换%PublishProfile.Username%%PublishProfile.Password%,并可能修改Production-publishProduction.pubxml

请注意,只需要Password参数(考虑到.pubxml文件中提供了UserName)

我实际上最后写了关于如何使用TeamCity编译和部署asp.net核心站点的博客文章: How to deploy ASP.NET Core sites using Teamcity to Azure/IIS … or just command line