Autodeployment .NET Core Web APP

Hello,

I try to automate my testing project in teamcity, so it will pull the files after git push, build, publish on server and run. And I went with two problems:

 

One is sending via SSH just one folder with all the content.

I have .NET Publish step with output directory Published, and than I try to use SSH Upload.

When I use +:**/* it copy whole project, I tried +:Published, +:Published/*, etc. but or it didnt coppy all the files, or it copied published few times and nested it somehow.

 

Second one is more important. When I upload my project, I execute it via SSH Exec step with command:

/home/user/test/Published/./test

And the project run, but the agent is blocked, until I won't stop it manualy. The problem is that .net app have that annoying, press ctrl + c to stop app, and I have no idea how to turn it off.

[08:19:26][Step 5/5] Executing commands: /home/user/test/Published/./test on host [10.0.0.1]
[08:19:28][Step 5/5] info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
[08:19:28][Step 5/5] User profile is available. Using '/home/user/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
[08:19:29][Step 5/5] Hosting environment: Production
[08:19:29][Step 5/5] Content root path: /home/user
[08:19:29][Step 5/5] Now listening on: http://localhost:5000
[08:19:29][Step 5/5] Now listening on: https://localhost:5001
[08:19:29][Step 5/5] Application started. Press Ctrl+C to shut down.
0
1 comment

Hi,

 

When copying the files, "Published" or "Published/*" will copy different things. One will copy the contents of the Published folder, while the other one will copy the published folder itself, which can give the impression of nesting. Furthermore, SSH Upload is an SSH Upload. It will not remove the previous contents of the folder on the remote server, just overwrite the matching contents.

 

About the issue with executing, this is your application running that code, it is your application which starts and waits for you. You should change the code so that it doesn't do that and eventually finishes. You cannot send a remote Ctrl + C (stopping the build should perform a very similar task). This said, it's your application that needs to run some code. The code right now seems to be opening 2 ports for listening. If you don't close it yourself, it will run forever, and new attempts will fail until it's closed, and new attempts of running it will fail because the ports are already open.

0

Please sign in to leave a comment.