在命令行中将 ASP.Net 核心应用发布到 Azure 以静默方式失败
Publishing ASP.Net Core app to Azure silently fails in command line
我正在尝试将 dotnet 核心应用程序发布到 Azure。我创建了一个发布配置文件并使用 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 部署?
通过 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-publish
和 Production.pubxml
请注意,只有 Password
参数是必需的(考虑到您的 .pubxml 文件中提供了用户名)
实际上我最终写了一篇关于如何使用 TeamCity 编译和部署 asp.net 核心站点的博客文章:
How to deploy ASP.NET Core sites using Teamcity to Azure/IIS … or just command line
我正在尝试将 dotnet 核心应用程序发布到 Azure。我创建了一个发布配置文件并使用 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 部署?
通过 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-publish
和 Production.pubxml
请注意,只有 Password
参数是必需的(考虑到您的 .pubxml 文件中提供了用户名)
实际上我最终写了一篇关于如何使用 TeamCity 编译和部署 asp.net 核心站点的博客文章: How to deploy ASP.NET Core sites using Teamcity to Azure/IIS … or just command line