简体   繁体   English

“dotnet publish”命令行会跳过部署到Azure Functions

[英]The 'dotnet publish' command line skips deployment to Azure Functions

I'm setting up some DevOps for my site, and so far I've used the following command for deployment on two ASP.NET Core apps, with success: 我正在为我的站点设置一些DevOps,到目前为止,我已经使用以下命令在两个ASP.NET Core应用程序上进行部署,并且成功:

dotnet publish ProjectName.csproj /p:PublishProfile="PublishProfileName" /p:Password=password

I've just created an Azure Function, using the V2 runtime and .NET Core 2.1, as suggested for all new projects (see here https://azure.microsoft.com/en-us/blog/introducing-azure-functions-2-0/ ), but if I use the same command, I find that it only publishes it to a local folder and doesn't seem to deploy the project to Azure. 我刚刚为所有新项目建议使用V2运行时和.NET Core 2.1创建了Azure功能(请参阅https://azure.microsoft.com/en-us/blog/introducing-azure-functions- 2-0 / ),但如果我使用相同的命令,我发现它只将它发布到本地文件夹,似乎并没有将项目部署到Azure。

If I use the MSBuild equivalent, it seems to also miss out the deployment stage. 如果我使用MSBuild等价物,它似乎也错过了部署阶段。

I'm guessing its to do with the project type in some way not having the appropriate build targets, but I'm not sure how to track this further. 我猜它是以某种方式处理项目类型而没有适当的构建目标,但我不确定如何进一步跟踪它。

I can download the publish settings from Azure, import them into Visual studio and publish through VS, so it seems like if the VS path works, this might be a regression or bug in the tooling somewhere, rather than something unsupported? 我可以从Azure下载发布设置,将它们导入Visual Studio并通过VS发布,所以看起来如果VS路径有效,这可能是某个地方工具中的回归或错误,而不是不支持的东西?

I'm using: 我正在使用:

  • Visual Studio 15.8.8 +28010.2048 Visual Studio 15.8.8 +28010.2048
  • Azure Functions and Web Jobs Tools 15.9.02046.0 Azure功能和Web作业工具15.9.02046.0

If I shouldn't be using dotnet publish with Azure functions, what should I be using instead for command line CD? 如果我不应该使用Azure功能使用dotnet发布,那么我应该使用什么来代替命令行CD? I've seen references to the Azure Function CLI tools, but I'd prefer not to have to install a package manager on our build agents if it can be done through other tooling. 我见过对Azure Function CLI工具的引用,但如果可以通过其他工具完成,我不希望在构建代理上安装包管理器。

In the end, with the help of the answers and comments (thanks all), I have an MSBuild command line that is working to deploy my .NET Core 2.1 Function project: 最后,在答案和评论的帮助下(感谢所有),我有一个MSBuild命令行,用于部署我的.NET Core 2.1 Function项目:

msbuild /p:DeployOnBuild=True /p:PublishProfile=somename.pubxml /p:Configuration=Release

It is, however, worth noting the following: 但是,值得注意的是:

General .NET Core publishing notes 一般.NET Core发布说明

  1. If you miss-spell the publish profile name, it will silently skip deployment (no warning or error). 如果您错过拼写发布配置文件名称,它将默默跳过部署(无警告或错误)。

Differences between ASP.NET Core and .NET Core Functions deployment ASP.NET Core和.NET Core Functions部署之间的差异

  1. If you use 'dotnet publish', it will always skip deployment. 如果您使用'dotnet publish',它将始终跳过部署。

  2. If you don't specify /p:DeployOnBuild=True, it'll skip deployment. 如果未指定/ p:DeployOnBuild = True,则会跳过部署。

If you do not want to have "a package manager" on your build agents you have to option to make a zip deploy of your function app. 如果您不想在构建代理上拥有“包管理器”,则必须选择对功能应用程序进行zip部署 Details can be found on the MSDN here: 有关详细信息,请访问MSDN:

https://docs.microsoft.com/en-us/azure/azure-functions/deployment-zip-push#rest https://docs.microsoft.com/en-us/azure/azure-functions/deployment-zip-push#rest

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure DevOps Build Pipeline:“publish”命令正在执行“dotnet build”而不是“dotnet publish” - Azure DevOps Build Pipeline: 'publish' command is executing 'dotnet build' instead of 'dotnet publish' dotnet 发布命令的 azure-pipelines.yml 中的转义空格 - Escape spaces in azure-pipelines.yml for the dotnet publish command 我可以在 Azure DevOps 中使用 dotnet publish 命令发布 .net 框架 4.7.1 解决方案吗 - Can I publish .net framework 4.7.1 solution with dotnet publish command in Azure DevOps dotnet publish 调用对 Azure devops 的意外调用 - dotnet publish invokes unexpected call to Azure devops 如何发布到Azure Functions Runtime - How to publish to Azure Functions Runtime 我可以使用 dotnet publish 命令来构建 .NET Framework 应用程序吗? - Can I use dotnet publish command to build .NET Framework applications? 如何使用dotnet在命令行中传递参数? - How to pass arguments in command line using dotnet? 发布目标中缺少 VS 2019 azure 功能 - VS 2019 azure functions missing in publish target 如何使用远程主机的 dotnet 发布执行依赖于框架的部署 - How to execute framework-dependent deployment using dotnet publish with remote host Azure 函数:代理 + 部署槽 + 查询字符串参数 - Azure Functions: Proxy + Deployment Slot + Querystring parameter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM