Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Deploying ASP.NET Core application via FTP

Jason Miller March 27, 2020

Hello! I'm fairly new to Pipelines and .NET Core and I'm trying to figure out how to build and deploy my application via FTP using Pipelines.

I currently have the following setup in my Pipelines .yml file and the build portion seems to be running just fine.

image: mcr.microsoft.com/dotnet/core/sdk:3.1

pipelines
:
default:
- step:
caches:
- dotnetcore
script:
- export PROJECT_NAME=WebApplication
- dotnet restore
- dotnet build $PROJECT_NAME

 

I see there is an FTP pipe that can be added that looks pretty straightforward if being used with static files in my repo, but I'm unclear how to integrate this with my existing .NET Core build.

script:
- pipe: atlassian/ftp-deploy:0.3.1
variables:
USER: '<string>'
PASSWORD: '<string>'
SERVER: '<string>'
REMOTE_PATH: '<string>'
LOCAL_PATH: '<string>'

DEBUG: '<boolean>'

EXTRA_ARGS: '<string>'

DELETE_FLAG: '<boolean>'

 

My first question would be: Can this FTP pipe run inside my existing script tag just below "dotnet build"? Or do I need to define a seperate step and set everything up there? And, in either scenario, how do I define my local path to point to wherever my .NET application is building too? As of right now I'm unclear where those build files live after the build completes.

Any assitance here will be much appricated and hopefully these are not completely stupid questions. Just trying to get my brain wrapped around this so I'm not manually uploading my app everytime.

Thanks!

1 answer

1 accepted

1 vote
Answer accepted
Jason Miller March 27, 2020

Figured this out myself with some trial and error and digging through the logs a bit. Here is the working version of my pipelines config file in hopes this will help someone else out who is trying to use FTP with ASP.NET Core builds.

image: mcr.microsoft.com/dotnet/core/sdk:3.1

pipelines
:
branches:
master:
- step:
caches:
- dotnetcore
script:
- export PROJECT_NAME=WebApplication
- dotnet restore
- dotnet build $PROJECT_NAME
- pipe: atlassian/ftp-deploy:0.3.1
variables:
USER: $PROD_USERNAME
PASSWORD: $PROD_PASSWORD
SERVER: $PROD_FTP
REMOTE_PATH: $PROD_PATH
LOCAL_PATH: $BUILD_PATH
Chihab Jraoui May 9, 2020

Thank you, that was helpful for me :)

Jason Miller May 9, 2020

Hi @Chihab Jraoui, I'm glad this helped you out. One thing I ran into in my case that is not covered in this thread is that even though I was able to upload the new build via FTP, the DLLs remained loaded in memory on the server, so pushing a new build didn't update anything. If you control the server you can easily recycle the application pools, but in my case, it was a 3rd party hosting company that I had to submit a support ticket to get that done. I ended up finding a workaround by deleting all files, uploading an "app_offline.htm" file (which I guess tells IIS to release the app from memory), then upload the new build from there. I was not able to automate this in Pipelines (as of yet anyway) but was able to manually get the project deployed for my client without contacting support every time. I am hoping to double back on this when I have time to see if it can be fully automated.

Chihab Jraoui May 10, 2020

I didn't run into this case yet, I'm trying to setup the pipelines to automate the workflow for my team. I will keep your advice in mind for sure. Thanks again.

Varick Johnson September 26, 2022

Hi @Jason Miller  I'm exactly dealing with your case did you fully automated the pipeline ?is there any command to remove existing  files from server before pushing a new build?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events