.net尝试编译配置文件

时间:2018-12-06 22:44:29

标签: msbuild .net-4.0

我以前从未见过Visual Studio尝试编译web.config文件。但是我几乎在文件的每一行上都遇到编译错误。

第一行包含

<?xml version="1.0"?>    

我得到7个错误。

Severity    Code    Description Project File    Line    Suppression State
Error   CS1022  Type or namespace definition, or end-of-file expected   Portal  {Path}\Views\Web.config 1   Active
Error   CS1031  Type expected   Portal  {Path}\Views\Web.config 1   Active
Error   CS1002  ; expected  Portal  {Path}\Views\Web.config 1   Active
Error   CS0116  A namespace cannot directly contain members such as fields or methods   Portal  {Path}\Views\Web.config 1   Active
Error   CS1022  Type or namespace definition, or end-of-file expected   Portal  {Path}\Views\Web.config 1   Active
Error   CS1031  Type expected   Portal  {Path}\Views\Web.config 1   Active
Error   CS1022  Type or namespace definition, or end-of-file expected   Portal  {Path}\Views\Web.config 1   Active

为什么会编译该文件,如何告诉我不要?

1 个答案:

答案 0 :(得分:0)

从项目中删除文件,然后重新添加即可解决该问题。 前后比较,csproj的文件列为“编译”而不是“内容”。

<Content Include="{Path}\Web.config" />