编译ASP.NET网站时出现MSBuild错误

时间:2021-05-22 05:35:27

I get the following error when I try to compile an asp.net site using a custom build script.

当我尝试使用自定义构建脚本编译asp.net站点时出现以下错误。

error ASPCONFIG: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS.

Although the description is in detail I do not understand what it means exactly. I have not configured IIS to host this website and I don't think I will be able to as I am running Vista Home Basic version. So the website cannot be built using custom scripts?Please reply as I want to test this feature.

虽然详细描述我不明白它究竟意味着什么。我没有配置IIS来托管这个网站,我不认为我能够运行Vista Home Basic版本。所以无法使用自定义脚本构建网站?请回复,因为我想测试此功能。

5 个解决方案

#1


4  

It is likely that your web.config file is placed in a directory that is not the root of the application. On most versions of IIS, you can convert any folder on your web site to an application root:

您的web.config文件可能放在不是应用程序根目录的目录中。在大多数IIS版本上,您可以将网站上的任何文件夹转换为应用程序根目录:

  1. Open IIS and navigate to the appropriate folder
  2. 打开IIS并导航到相应的文件夹
  3. Right-click on the folder, select properties
  4. 右键单击该文件夹,选择属性
  5. Under Application Settings, and beside Application name, click Create
  6. 在Application Settings下,在Application name旁边,单击Create
  7. Apply and close
  8. 申请并关闭

If this does not fix your problem, there may be another configuration error, either with IIS or your application.

如果这不能解决您的问题,则可能存在其他配置错误,无论是使用IIS还是应用程序。

#2


48  

I had this SAME EXACT problem and finally discovered a rogue Web.config was placed in my obj folder ... do yourself a favor and do a search in all the sub-directories for a web.config file. I deleted it and all was back to normal.

我有这个相同的问题,最后发现一个流氓Web.config被放置在我的obj文件夹中...帮自己一个忙,并在web.config文件的所有子目录中搜索。我删除了它,一切都恢复正常了。

#3


15  

The rogue web.config file in the obj folder is most likely to be caused when you do a Publish Web Site. So just clean it up after you've done the publish.

当您执行发布网站时,最有可能导致obj文件夹中的流氓web.config文件。所以只需在完成发布后清理它。

#4


4  

if this happens after the virtual-directory is already created do the following:

如果在已创建虚拟目录后发生这种情况,请执行以下操作:

  • right-click on web.config
    • properties
      • Build Action: Content
      • 构建行动:内容
      • Copy to Output directory: Do not copy
      • 复制到输出目录:不要复制
    • 属性构建操作:内容复制到输出目录:不要复制
  • 右键单击web.config属性构建操作:内容复制到输出目录:不要复制
  • if transformed (apply to all configurations)
    • properties
      • Build Action: None
      • 构建动作:无
      • Copy to Output directory: Do not copy
      • 复制到输出目录:不要复制
    • 属性构建操作:无复制到输出目录:不复制
  • 如果转换(适用于所有配置)属性构建操作:无复制到输出目录:不复制

#5


0  

In IIS, go to the folder that the app runs under, right click it, go to properties. On the Directory tab, look for "Application settings". Click the create button.

在IIS中,转到应用程序运行的文件夹,右键单击它,转到属性。在“目录”选项卡上,查找“应用程序设置”。单击“创建”按钮。

#1


4  

It is likely that your web.config file is placed in a directory that is not the root of the application. On most versions of IIS, you can convert any folder on your web site to an application root:

您的web.config文件可能放在不是应用程序根目录的目录中。在大多数IIS版本上,您可以将网站上的任何文件夹转换为应用程序根目录:

  1. Open IIS and navigate to the appropriate folder
  2. 打开IIS并导航到相应的文件夹
  3. Right-click on the folder, select properties
  4. 右键单击该文件夹,选择属性
  5. Under Application Settings, and beside Application name, click Create
  6. 在Application Settings下,在Application name旁边,单击Create
  7. Apply and close
  8. 申请并关闭

If this does not fix your problem, there may be another configuration error, either with IIS or your application.

如果这不能解决您的问题,则可能存在其他配置错误,无论是使用IIS还是应用程序。

#2


48  

I had this SAME EXACT problem and finally discovered a rogue Web.config was placed in my obj folder ... do yourself a favor and do a search in all the sub-directories for a web.config file. I deleted it and all was back to normal.

我有这个相同的问题,最后发现一个流氓Web.config被放置在我的obj文件夹中...帮自己一个忙,并在web.config文件的所有子目录中搜索。我删除了它,一切都恢复正常了。

#3


15  

The rogue web.config file in the obj folder is most likely to be caused when you do a Publish Web Site. So just clean it up after you've done the publish.

当您执行发布网站时,最有可能导致obj文件夹中的流氓web.config文件。所以只需在完成发布后清理它。

#4


4  

if this happens after the virtual-directory is already created do the following:

如果在已创建虚拟目录后发生这种情况,请执行以下操作:

  • right-click on web.config
    • properties
      • Build Action: Content
      • 构建行动:内容
      • Copy to Output directory: Do not copy
      • 复制到输出目录:不要复制
    • 属性构建操作:内容复制到输出目录:不要复制
  • 右键单击web.config属性构建操作:内容复制到输出目录:不要复制
  • if transformed (apply to all configurations)
    • properties
      • Build Action: None
      • 构建动作:无
      • Copy to Output directory: Do not copy
      • 复制到输出目录:不要复制
    • 属性构建操作:无复制到输出目录:不复制
  • 如果转换(适用于所有配置)属性构建操作:无复制到输出目录:不复制

#5


0  

In IIS, go to the folder that the app runs under, right click it, go to properties. On the Directory tab, look for "Application settings". Click the create button.

在IIS中,转到应用程序运行的文件夹,右键单击它,转到属性。在“目录”选项卡上,查找“应用程序设置”。单击“创建”按钮。