我正在 Visual Studio 2010 中处理一个 php 网站。在我尝试发布之前一切都很顺利。该网站的发布版本中不包含任何 php 文件。我该如何解决这个问题?
我在这个帖子 (Visual Studio 2010 Web Publish 缺少文件) 中读到,您可以更改 BuildAction 属性基于每个文件。太好了,但是我如何自动对分布在庞大文件夹层次结构中的 112 个和一些奇数文件执行此操作?我可以更改每个以 *.php
结尾的文件的默认 BuildAction
吗?我什至愿意在命令行上执行此操作,因为至少这样我可以迭代文件列表并为每个文件更改它。
编辑:我意识到一些事情:BuildAction
属性存储在.vbproj
文件中,以这种形式:
<ItemGroup>
<Content Include="aboutus.php" />
<None Include="login.php" />
这就是它的内容看起来就像是在我更改aboutus.php(通过VS)的BuildAction
之后,但没有更改login.php的。明智地使用查找和替换会起作用,但会很乏味。这是我的临时解决方案。
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.
发布评论
评论(2)
通过 VS IDE 更改多个文件的构建操作的一种方法是选择所需的所有文件,然后选择属性,然后设置构建操作。我知道它绝对适用于以相同扩展名结尾的所有文件。
我要考虑的另一件事是使用 Visual Studio 宏来获得所需的结果,请看这里
在 MSDN 网站上
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
我并没有真正找到一个好的解决方案,但我确实找到了一个肮脏的解决方案。我意识到包含 替换为 ,然后替换每个
BuildAction
设置的.vbproj
文件采用 XML 格式。因此,我将每次出现的与
。这不是一个理想的解决方案,因为它还影响了许多不应该包含在网站发布版本中的文件,但事实就是如此。
不过,我确实从 KevDog 那里学到了 链接,可以为 Visual Studio 编写影响
BuildAction
属性的自定义文件模板使用该模板创建的任何新文件。这在我的情况下是不合适的,因为它只影响新生成的文件,但它可能会帮助那些从项目一开始就发现这个问题的人——比如我,在我的下一个 php 项目中。I didn't really find a good solution, but I did find a dirty fix. I realised that the
.vbproj
file--which contains theBuildAction
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.