How to deploy files to remote server using visual studio RRS feed

  • Question

  • We have a projects which uses lots of fixed format as input files. We are trying to deploy those files into visual studio so the version has controls. 

    We don't want to put those files inside of the c# code project, so there will be no dependencies on the c# project and those files. 

    We tried to created a project to deploy those files only using visual studio, but we cannot find better solution.  We tried to use Build Event , post deploy etc. But it is not so clear or easy to deploy files only. 

    Are there any clear way to deploy files to remote server via visual studio?


    Monday, September 14, 2020 8:19 PM

All replies

  • you can create an empty project and add files to it. Before adding files, modify the project file in a text editor to remove any reference to targets that compiles code. If you want your can remove everything except the root node.  

    Actually deploying files with such a project file would require knowing some msbuild. The Copy task would copy files.  Or if you want something like sftp, you can use the Exec Task with external software.

    If you have experience with make files, you can also create a makefile project

    Visual C++ MVP

    Monday, September 14, 2020 10:36 PM
  • Thanks Sheng for the help.

    I noticed if I create an empty project using wcf, it will allow me to push folder or files into target based on publish files. I am wondering if I  create such empty wcf project but only to push files, would it be odd ? 

    Wednesday, September 16, 2020 5:38 PM
  • You can document the code with readme.txt, just remember skip the file when publishing... or move it to be a solution item. 

    Visual C++ MVP

    Wednesday, September 16, 2020 5:42 PM
  • It depends on several factors including the source control system you're using, how those files are used in your project and how many there are.

    If you're using a file based SCC such as Git then putting the files anywhere in your repo folder is sufficient to get them into version control. However if you're using something like Tfvc then you'll have to explicitly add those files in. Furthermore they will be downloaded whenever someone grabs that project.

    If your project(s) require these files to work then they should be part of the project folder structure. Otherwise you need to handle situations like what if the files don't exist. If you're talking about massive data files then perhaps a better approach is to put them on a shared server instead but that would be a boundary case.

    In general I would recommend you add the data files directly to the project that needs them. This will have no impact on the IDE on build process since it won't care about those files. If you're using a pre-SDK format project file then exclude that folder structure from the project file and they won't show up in the IDE either. This is the easiest approach and should be the default.

    If this is a web app then marking the folder structure as Content in the build actions will ensure it all gets deployed as part of publishing. If this is not a web app then putting the folder structure into the output directory (generally via a post-build event) will accomplish the same thing.

    Alternatively you can create a folder at the solution level and put your data files in there. We tend to do that for documentation. You can add virtual folders and files unrelated to projects in there and still see it in Solution Explorer. Of course if these files are needed inside a project's output then you'll need a post build event (or a deploy task on your build server) to copy them into the project which is slower. 

    Michael Taylor

    Wednesday, September 16, 2020 7:08 PM
  • Yup. I also think the key is source control.

    Lots of source control providers like "Azure DevOps Service"/GitHub/GitLab and so on provides runners that can build your source code, run tests on it, and automatically deploy to target server based on the branch you committed the source code to. There is not much need to add deployment related code in your project. You can just add production related settings files to a side branch (or even a different repository for download via the build script if you don't want your developers to see them) to merge before build for deployment.

    Thursday, September 17, 2020 2:40 AM