0

I'm using a build process that create hashed js and css files. As these files are builded, they aren't versionned, and they aren't included in the VS project.

I'd like them to be published with the application when using the VS publish to web.

How can I tell VS 2012 to include all the content in the public folder (even if not included in the project) on publish?

Simon Boudrias
  • 42,953
  • 16
  • 99
  • 134
  • Did you try setting the build action for each item to Content? – Mike Cheel Sep 26 '13 at 16:03
  • The files aren't created when the deploy process is launched, and the files are simply .js and .css. – Simon Boudrias Sep 26 '13 at 17:30
  • If you want them included in the build which then includes them in the output they should have their build action set to Content. Then when deployment kicks in they are there. Visual Studio uses web deploy in the background so if the files are in the correct location that web deploy pulls from they should be synced. – Mike Cheel Sep 27 '13 at 13:42
  • And how can I set the build action to content? I set this on a folder? – Simon Boudrias Sep 27 '13 at 14:15
  • First make sure that the files are part of the project (i.e. show in the list). Next open the Properties dialog (F4). Select each file in the project you want to keep (one by one) and choose Content for Build Action. – Mike Cheel Sep 27 '13 at 16:47
  • That don't work for me because content is dynamically created. Here is the answer I was looking for: http://stackoverflow.com/questions/2059562/in-visual-studio-how-can-i-set-the-build-action-for-an-entire-folder Thanks for your help though, you pointed me in the good direction! – Simon Boudrias Sep 27 '13 at 17:10

1 Answers1

0

To resolve this, you need to add a config to your .csproj config.

Inside <Project>, simply add a target:

  <Target Name="AfterBuild">
    <ItemGroup>
      <Content Include="public\**\*.*">
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      </Content>
    </ItemGroup>
  </Target>
Simon Boudrias
  • 42,953
  • 16
  • 99
  • 134