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.
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.