0

I'm working with a php website in Visual Studio 2010. Everything was going well until I tried to publish. None of the php files are included in the published version of the website. How do I fix this?

I read in this thread (Visual Studio 2010 Web Publish missing a file) that you can change the BuildAction property on a per-file basis. Great, but how do I do this automagically for eleventy-two and some-odd files spread throughout a massive folder hierarchy? Could I change the default BuildAction for, say, every file that ends in *.php? I'm even willing to do this on the command-line, because, at least then, I can iterate through a list of the files and change it for each of them.

Edit: I realised something: The BuildAction Property is stored in the <Project_Name>.vbproj file, in this form:

  <ItemGroup>
    <Content Include="aboutus.php" />
    <None Include="login.php" />

This is what it looks like just after I changed the BuildAction of aboutus.php (via VS), but not of login.php. Judicious use of Find-and-Replace would work, but would be tedious. That's my temporary solution.

Community
  • 1
  • 1
jpaugh
  • 6,634
  • 4
  • 38
  • 90

2 Answers2

1

One way you can change the build action of multiple files through the VS IDE is by selecting all the files you want, then properties, then setting the build action. I know that it definitely works for all files that end in the same extension.

The other thing I would think about is a Visual Studio macro to get the desired result, take a look here on the MSDN site

KevDog
  • 5,763
  • 9
  • 42
  • 73
  • Thanks for the link. I hope to avoid manually selecting all of these files: they're spread throughout a pretty massive directory hierarchy – jpaugh Jun 28 '11 at 20:54
  • Not a problem. I hate writing VS macros, but if you are going to have more than one solution that requires this, it is probably worth it. – KevDog Jun 28 '11 at 20:58
0

I didn't really find a good solution, but I did find a dirty fix. I realised that the .vbproj file--which contains the BuildAction setting, is in XML format. So, I replaced every occurrence of <None ... with <Content ..., and then each </None> with </Content>. This wasn't an ideal solution, because it also affected many files that shouldn't have been included in the published version of the website, but it is what it is.

I did learn, however, from KevDog,s link, that it is possible to write custom file templates for Visual Studio that affect the BuildAction attribute of any new files created with that template. This wasn't appropriate in my case, because it affects only newly generated files, but it might help someone else who sees this problem coming from the beginning of a project--like me, on my next php project.

jpaugh
  • 6,634
  • 4
  • 38
  • 90