locked
Files excluded on publish RRS feed

  • Question

  • User-1496267892 posted

    Hi,

    I have an mvc / webapi application which references a subproject (output: dll) which contains text files that are required at runtime. The files are marked as "Content" and are copied to output directory if they are newer than the existing ones. Now if I build my application and look inside the bin folder I can see the files from the sub project have been copied there -> running the project locally works fine. If I use the publish wizard and publish to a local folder the content files from the sub project are not copied. Deploying the project this way would result in a runtime exception since the files are not found. 

    What setting am I missing to get this working?

    Kai

    [Edit]: Using Visual Studio 2015

    Monday, March 14, 2016 12:47 PM

Answers

  • User-1068454292 posted

    Hi TGKN,

    The files are marked as "Content" and are copied to output directory if they are newer than the existing ones.

    Before publish , you could use post-build events window to copy your files.

    post build

    You can refer to Copy file(s) from one project to another using post build eventVS2010

    Best regards

    Pan

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 15, 2016 8:48 AM
  • User-1068454292 posted

    Hi TGKN,

    I wrote a demo with Main project and Sub project, and after publishing main project,

    you can see the file you include in Sub project.

    1,Create a web application as Main project.

    2.Create a Class Library project as sub project.

    3.Add reference of sub project to main project

    4..Add a test file named ‘test.xml’  and with the property ‘copy all ways’

    5.Publish main project

    6.find the ‘test.xml’ in out folder bin\

    Please check your steps.

    Best regards

    Pan

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 18, 2016 8:31 AM

All replies

  • Monday, March 14, 2016 1:01 PM
  • User-1496267892 posted

    Hi,

    Thanks for the reply. As far as I can see the article relates to deploying a clickOnce application. I am not trying to publish a clickonce application though, I am trying to publish a web application to azure or locally to the flesystem. I don't have a "Publish" tab in the project settings, I only have a "Publish/Package Web" tab and there is no "Application files" button.

    What's weird is that if I build the project (manualy start the build process from within Visual Studio) the content file from the subproject gets copied into the projects bin folder - but if I publish the project it automatically starts the build process and now the content file is not being copied to the bin folder - no wonder it's not being deployed. The build configuration used is the same in both scenarios. I'm a little lost here :-(

    Kai

    Tuesday, March 15, 2016 8:45 AM
  • User-1068454292 posted

    Hi TGKN,

    The files are marked as "Content" and are copied to output directory if they are newer than the existing ones.

    Before publish , you could use post-build events window to copy your files.

    post build

    You can refer to Copy file(s) from one project to another using post build eventVS2010

    Best regards

    Pan

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 15, 2016 8:48 AM
  • User-1496267892 posted

    Hi Pan,

    Thanks for the reply. You are right, a post build event may do the trick but I need to understand why the file is correctly included in the build when I start it manually and why it is not correctly inlcuded when the build is being started by the publishing wizard. I do plan to add several files from several subproject and adding Post build events for all of them seems to be the second best solution only...

    Kai

    Tuesday, March 15, 2016 8:52 AM
  • User-1068454292 posted

    Hi TGKN,

    why it is not correctly inlcuded when the build is being started by the publishing wizard.

    Do you include these files to your project?

    Like this:

    Best regards

    Pan

    Wednesday, March 16, 2016 8:53 AM
  • User-1496267892 posted

    Hi,

    Yes the files are included, marked as content. Again, these are files from a subproject referenced by the main project. If I build the main project (right click on project - build) the files of the subproject are correctly copied into the main projects bin folder. If the build is triggered by the publisher the files are not copied and thus not published...

    Wednesday, March 16, 2016 9:15 AM
  • User-1068454292 posted

    Hi TGKN,

    I wrote a demo with Main project and Sub project, and after publishing main project,

    you can see the file you include in Sub project.

    1,Create a web application as Main project.

    2.Create a Class Library project as sub project.

    3.Add reference of sub project to main project

    4..Add a test file named ‘test.xml’  and with the property ‘copy all ways’

    5.Publish main project

    6.find the ‘test.xml’ in out folder bin\

    Please check your steps.

    Best regards

    Pan

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 18, 2016 8:31 AM