mkloubert / vs-deploy

Visual Studio Code extension that provides commands to deploy files of a workspace to a destination.
https://marketplace.visualstudio.com/items?itemName=mkloubert.vs-deploy
MIT License
131 stars 24 forks source link

[Help wanted] How to FTP C++ executable? #130

Closed DavidA2014 closed 6 years ago

DavidA2014 commented 6 years ago

I have Build Task that builds a C++ executable. I want to copy that executable to a remote target using FTP. How would I do that using Deploy?

mkloubert commented 6 years ago

You can use "deploy on change" feature which can deploy things that are change, like generated executables.

DavidA2014 commented 6 years ago

Thanks for your answer.

DavidA2014 commented 6 years ago

I want to deploy file ../srcpath/outfile to /dstpath/outpath, where srcpath and destpath are different. So I tried:

"deploy": {
    "button": {
      "enabled": true,
      "test": "Deploy myApp",
      "packages": [ "myApp" ]
    },

    "packages": [
        {
            "name": "myApp",
            "description": "Package version 2.3.4",
            "files": [
                "myApp.out"
            ],
            "loadFrom": "../srcpath/",
            ],
            "deployOnSave": true,
            "targets": [
              "myApp"
            ]
        }
    ],

    "targets": [
        {
            "type": "sftp",
            "name": "myApp",
            "description": "my target",
            "dir": "destpath",
            <snip>
        }
    ]
}

Is that strategy (using loadFrom) the correct way to go?

I get error:

"Loading data from 'c:\SVNProj\myPath\' failed: Error: EISDIR: illegal operation on a directory, read"

but the path shown in the error message is valid

mkloubert commented 6 years ago

Because you use a build task, you should use deploy on change instead.

The difference is that "deploy on save" is fired when you explicitly save the file in your editor, and "deploy on change" means that anything, like you or a background build task, changes a file.

Btw.: The loadFrom is used in a wrong way here. You can define a path to a file with that setting, which JSON data should be merged with the package.

{
    "deploy": {
        "packages": [
            {
                "name": "myApp project",

                "deployOnChange": {
                    "files": [ "myApp.out" ],
                    "useTargetList": true
                },

                "targets": [ "myApp" ]
            }
        ],

        "targets": [        
            {
                "name": "myApp",
                "type": "sftp"
            }
        ]
    }
}

Now the extension will deploy myApp.out file to myApp SFTP server, when it is changed by build task.

DavidA2014 commented 6 years ago

Thanks for your reply. So I now have:

"deploy": {

    "packages": [
        {
            "name": "My project",

            "deployOnChange": {
                "files": [
                    "Source/LedaAP_workbench/LedaAP/NonDebug/LedaAP.out"
                ],
                "useTargetList": true
            },

            "targets": [ "ledapc" ]
        }
    ],

    "targets": [
        {
            "type": "sftp",
            "name": "ledapc",
            "dir": "/home/mydir"
            <snip>
        }
    ]
}

but nothing is appearing in /home/mydir on the target after the project gets built. Can you see anything wrong?

Please note that I would like the destination to be:

/home/mydir/LedaAP.out

not

/home/mydir/Source/LedaAP_workbench/LedaAP/NonDebug/LedaAP.out

DavidA2014 commented 6 years ago

Sorry, the file I specified is being deployed successfully. However, my second question is still valid, that is:

I want the destination to be:

/home/mydir/LedaAP.out

not

/home/mydir/Source/LedaAP_workbench/LedaAP/NonDebug/LedaAP.out

Is it possible to configure that in Deploy's settings?

mkloubert commented 6 years ago

Yes, you can use folder mappings.

DavidA2014 commented 6 years ago

Thanks, folder mappings does what I need.

I am deploying one file:

    "packages": [
        {
            "name": "My project",

            "deployOnChange": {
                "files": [
                    "Source/<snip>/LedaAP.out"
                ],
                "useTargetList": true
            },

            "targets": [ "ledapc" ]
        }
    ],

but get two deploy messages:

Deploying file 'c:/SVNProj/<snip>/LedaAP.out' to '/home/me' ('ledapc')... 
Deploying file 'c:/SVNProj/<snip>/LedaAP.out' to '/home/me' ('ledapc')...  [OK]
Finished
[OK]
Finished

Is that expected?

mkloubert commented 6 years ago

The build task is creating the LedaAP.out in background and you do not save this file in your editor, right?

Maybe the build task changes / creates the file twice, what means that "file change event" is also fired twice.

DavidA2014 commented 6 years ago

Yes, it's built in the background. Thanks for your explanation.