使用Visual Studio发布部署文件夹后,IIS上的编译错误

时间:2017-02-01 11:52:11

标签: asp.net-mvc iis deployment

我们正在使用Visual Studio 2015的Publish选项部署MVC项目。当我们将所有文件复制到服务器时,我们收到了一个可怕的错误:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: BC30451: 'Styles' is not declared. it may be inaccessible due to its protection level

有趣的是,如果我们在发布模式下手动编译项目,然后将bin和views文件夹复制到服务器,它将再次运行。

有人可以帮助我们吗?

2 个答案:

答案 0 :(得分:1)

当有些文件(如视图)保存在文件系统中但未包含在Visual Studio项目中时,我遇到了一些错误。检查项目中是否包含所有必要文件。

答案 1 :(得分:0)

最后,我们找到了问题所在。

Views文件夹中的web.config文件已从项目中排除(谁知道原因?)。此文件包含剃刀配置(如Styles.Render)。当我们发布项目时,没有复制此文件,因此服务器中的编译过程失败。