Search code examples
asp.net-mvcvisual-studio-2012publishpublishing

When publishing, what is exactly supposed to be published?


I'm not used with "publishing" a project via visual studio. I'm trying to do so since yesterday and I've found out these things:

  1. All the images contained in my application in a specific folder (example: MyProject/Images/Image1.jpeg) are only copied the same way they are in my project;
  2. None of my controllers/utility class appears in the published project;
  3. However the views are presents and the javascript files as well, but as they are, so a MyApp.js will be copied as a MyApp.js.

So my question is: is it supposed to be that way? What about my logic, ain't it not supposed to be copied as well? And shouldn't it be compressed, compiled, or protected in a dll, else everyone will be able to see my code in public, which I do not want?

Feel free to teach me what's a publish is supposed to do and what went wrong. thanks!


Solution

  • Publish is supposed to do almost what you mentioned only..

    • Images in content folder
    • any stylesheets in the content folder
    • Scripts in script folder
    • All View files Anything with Build Action = Content
    • The compiled files form the dll of your binary & dependencies

    Infact all the images, css, javascripts will also have buildaction set to content only.

    If you have a file selected in the project and it is not found in the folder, if its build action is "content", the build will succeed but the publish may fail. So in this case you may have to exclude the file if it is not necessary or add the file in the folder

    Most of the automatic build systems like cruise control also do the same though with quite an advanced interface.

    Your logic in c# or vb.net is already compiled into the binaries. But any script or styles or scripts inside html won't be protected. But bundling the scripts and styles using the BundleConfig may protect it to some extent.