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:
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.
If I use the MSBuild equivalent, it seems to also miss out the deployment stage.
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?
I'm using:
If I shouldn't be using dotnet publish with Azure functions, what should I be using instead for command line 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.
Description. dotnet publish compiles the application, reads through its dependencies specified in the project file, and publishes the resulting set of files to a directory. The output includes the following assets: Intermediate Language (IL) code in an assembly with a dll extension.
Publishing Self-Contained Framework Independent NET Core Application. Now we are going to execute the following command: dotnet publish –framework netcoreapp2. 2 –runtime linux-x64 –self-contained true.
Use the dotnet command to start the appdll> command to start your app. . NET Core 2.1 SDK doesn't produce platform-specific executables for apps published framework-dependent.
Build compiles the source code into a (hopefully) runnable application. Publish takes the results of the build, along with any needed third-party libraries and puts it somewhere for other people to run it.
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 /p:DeployOnBuild=True /p:PublishProfile=somename.pubxml /p:Configuration=Release
It is, however, worth noting the following:
General .NET Core publishing notes
Differences between ASP.NET Core and .NET Core Functions deployment
If you use 'dotnet publish', it will always skip deployment.
If you don't specify /p:DeployOnBuild=True, it'll skip deployment.
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. Details can be found on the MSDN here:
https://learn.microsoft.com/en-us/azure/azure-functions/deployment-zip-push#rest
Try the Azure CLI instead: https://learn.microsoft.com/en-us/cli/azure/functionapp/deployment?view=azure-cli-latest
or the function core tools: https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local#publish
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With