当我尝试使用它构建我的VS2010解决方案(包括Web站点项目)时,我遇到了奇怪的MSBuild任务行为.如果我在Visual Studio 2010中打开该解决方案并尝试编译它,它就可以工作.但是,如果我尝试从我的MSBuild脚本编译它,它会失败并显示错误.
我已经跟踪了这个事实,即WebSite目录中有一个User Control,它不使用后面的代码.
重现步骤:
1.)想象一下你有简单的解决方案.只需一个网站和两个用户控件:
网络\控件\ HelpButton.ascx:
<%@ Control Language="C#" ClassName="HelpButton" %>
<script runat="server">
private string _helpUrl;
public string HelpUrl
{
get { return _helpUrl; }
set { _helpUrl = value; }
}
</script>
Run Code Online (Sandbox Code Playgroud)
网络\ AnotherFolder\TestUserControl.ascx:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="TestUserControl.ascx.cs" Inherits="AnotherFolder_TestUserControl" %>
<%@ Register Src="~/Controls/HelpButton.ascx" TagPrefix="myCtrl" TagName="HelpButton" %>
<myCtrl:HelpButton runat="server" ID="HelpButton" />
Run Code Online (Sandbox Code Playgroud)
网络\ AnotherFolder\TestUserControl.ascx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class AnotherFolder_TestUserControl : System.Web.UI.UserControl
{
protected override void OnLoad(EventArgs …Run Code Online (Sandbox Code Playgroud)