It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Deploying ASP.NET Core application via FTP

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

0 votes
Answer accepted

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

Thank you, that was helpful for me :)

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.

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.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket Pipelines

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,051 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you