We have a solution containing a web application project (mostly webforms) and two separate "config" projects that are copied over depending on which client's specific output is needed.

Presently to "deploy" we zip up the web application folder, but of course it picks up files that were do not want such as project files and code files.

I would like to be able to use publish, but it seems to miss a lot of the files that come from one of the config projects during build. I have suspected its because it is not in the web app project, while being on the file system.

Are there any ways I can correct this? It is very unlikely we can change the way the config projects exist.

  • 1
    Um, batch files and XCopy? Feb 3, 2017 at 20:09
  • Make a copy of the solution, change the files around you suspect and hit publish to a dummy location. See if it works. Try it to a dummy location without changing anything first.
    – johnny
    Apr 4, 2017 at 21:31

2 Answers 2


Write a shell script which compiles your project in Release mode, copies exactly the files you like to deploy into a new folder and finally create the zip file.

  • That's one way to do it Doc, but MsBuild supports this natively.
    – RubberDuck
    Apr 4, 2017 at 21:13
  • @RubberDuck: there is more than one way to do it, but I guess your supposed solution will not be simpler than using a shell script.
    – Doc Brown
    Apr 4, 2017 at 21:59
  • Depends on your definition of simpler I suppose. My solution would work from inside of the IDE as well as on the CLI.
    – RubberDuck
    Apr 4, 2017 at 22:01
  • @RubberDuck: well, using a shell script decouples this intentionally.
    – Doc Brown
    Apr 5, 2017 at 5:41
  • ... and the syntax for copying files, creating folders, and calling an external zip program is IMHO simpler in a shell script than in MsBuild. A tool like MsBuild pays off, however, if one needs to manage the build dependencies here and make sure the "zip" file is created always and immediately when one part of the content was changed, for example.
    – Doc Brown
    Apr 5, 2017 at 5:57

Add a Copy Task to your project (mdbuild) file that copies in the correct files. Depending on the complexity of your project, you might want to add an afterbuild target to the solution itself.

In order to get your project to dynamically copy the correct files, you'll need to add a build configuration that allows you to switch between the two.

  • 1
    Presently it looks like we are using xcopy in the two "config" projects in post build command line fields. Apr 10, 2017 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.