locked
Publishing puts files/folders in "bin" directory instead of "root"? RRS feed

  • Question

  • User-1242214802 posted

    Hi All: I just ran into an issue where a website I'm publishing using webdeploy from VS2010 is putting certain folders/files in the bin diretory instead of the root of the website where they exist. It used to put them in the correct place...not sure what I changed to create this behavior?

    The folder in question has PDFs in it...if I drag a PDF from Windows Explorer into Solution Explorer it copies it into the project, but the default "build action" for the PDF is "do not copy"...if I manually change it "copy if newer" it does upload the PDF when I publish.

    my output log shows:

    Copying all files to temporary location below for package/publish:
    obj\Release\Package\PackageTmp.
    Start Web Deploy Publish the Application/package to https://[website]:8172/msdeploy.axd?site=forms ...
    Updating setAcl (forms).
    Updating setAcl (forms).
    Updating filePath (forms\bin\forms.dll).
    Updating filePath (forms\bin\forms.pdb).
    Updating filePath (forms\bin\forms.xml).
    Adding child filePath (forms\bin\pdfTemplates\Kit.pdf).
    Updating setAcl (forms).
    Updating setAcl (forms).
    Publish is successfully deployed.


    the folder "pdfTemplates" is in the root of the project...but I see it now in the "bin" directory as well...what is causing it to be placed there?

    Monday, October 22, 2012 4:44 PM

Answers

  • User1642585364 posted

    I think you've confused two different property fields.  The Copy To Output Directory has values of "Do not copy" and "Copy if newer".  For your web project content, you want this to be "Do not copy".  Why?  Because the Output directory refers to /bin (i.e. where the build output, your project .dll file, ends up).

    Instead you need to set the Build Action property to "Content" and it will include it in publishing.  By default in VS2010, any files that VS didn't know about would default to Build Action = None, which is ignored at publishing time.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 23, 2012 1:26 PM

All replies

  • User1642585364 posted

    I think you've confused two different property fields.  The Copy To Output Directory has values of "Do not copy" and "Copy if newer".  For your web project content, you want this to be "Do not copy".  Why?  Because the Output directory refers to /bin (i.e. where the build output, your project .dll file, ends up).

    Instead you need to set the Build Action property to "Content" and it will include it in publishing.  By default in VS2010, any files that VS didn't know about would default to Build Action = None, which is ignored at publishing time.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 23, 2012 1:26 PM
  • User-1242214802 posted

    Thanks jamlew...I never understood that distinction until now!

    Tuesday, October 23, 2012 2:00 PM
  • User-1242214802 posted

    I think you've confused two different property fields.  The Copy To Output Directory has values of "Do not copy" and "Copy if newer".  For your web project content, you want this to be "Do not copy".  Why?  Because the Output directory refers to /bin (i.e. where the build output, your project .dll file, ends up).

    Instead you need to set the Build Action property to "Content" and it will include it in publishing.  By default in VS2010, any files that VS didn't know about would default to Build Action = None, which is ignored at publishing time.

    Just a followup question...in a VS2010 VB.NET project, is there any way to specify that all PDF files be included when deploying? I realize that multiple PDFs can be selected at once and set to "content", but I don't want to have to do this manually every time new PDFs are added.

    I found a couple of threads on stackoverflow about manually editing the CSPROJ file to map PDF to "content" action, but I was wondering if there's a way to do it in the project settings? I noticed under "package/publish web" there's an "Items to deploy" dropdown that defaults to "only files needed to run this application". The other options are "all files in this project" and "all files in this project folder"...will either of those settings force PDFs to be deployed?

    I often exclude test webpages, so I don't want excluded files to be deployed accidentally.

    Friday, November 30, 2012 11:35 AM
  • User1642585364 posted

    I don't know of a feature built-in to VS that would support that.  You could consider writing a macro or an add-in or something to edit each file.

    The Build Action field for each file is determined either by the project template (when you create the project), or by the project type that you're using (e.g. Console app vs. Class Library vs. Web Application can all have their own behaviors).  In VS2010, pretty much all project types default to "None" unless it's a file type they recognize (e.g. .vb files get set to Compile, or .aspx files as Content).  In VS2012, we changed the Web Application projects to default to "Content" for all files, becaues we've found that a lot of folks have content file that they usually want to include (e.g. .zip files, .pdf files, .foo files, ...).  As far as I know, all other project types remain with Build Action="None" as the default.

    Side note: in VS2012 you'll need to exclude the test pages/content that you don't want to be deployed.  However, if you are using the Web Publishing feature, instead of setting the Build Action to "None" there are now ways to exclude files during publishing only (through the UI, there's a File Preview where you can unselect files; through the command line, there's a parameter you can pass in during publishing).  These new features are also available in VS2010 with the Azure SDK.

    Friday, November 30, 2012 12:53 PM