NANT for ASP.NET 2.0

P

prabhupr

Hi Folks

Not sure if this is the right group, if not please re-direct me to the
right one.

Here is my question
===============
When I compile my ASP.NET WEB project from VS 2005 (.NET Framework 2.0)
IDE, it works fine, but if I use NANT (Build Automation) it gives me an
error as follows:

[csc] Starting 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe
(@"C:\Documents and Settings\pprabhu\Local Settings\Temp\tmpDF.tmp")'
in 'C:\xxx\WebSite2'
[csc] c:\xxx\WebSite2\Default.aspx.cs(16,9): error CS0103: The name
'TextBox1' does not exist in the current context

BUILD FAILED

Here is the source code
=================
Default.aspx
~~~~~~~~~
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>

Default.aspx.cs
~~~~~~~~~~~~
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default : System.Web.UI.Page
{
//protected System.Web.UI.WebControls.TextBox TextBox1;
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Text = "Hello World";
}
}

site.build (NANT Build File)
~~~~~~~~~~~~~~~~~~~~
<?xml version="1.0" ?>
<project name="HRRelocproject" default="build">
<property name="project.type.actual" value="exe"/>
<property name="build.dir" value="build" />


<target name="build">
<echo message="'${project.type.actual}'" />
<call target="generate-assembly-info" />

<csc target = "library"
warnaserror = "true"
verbose = "true"
output = "${build.dir}/site.dll" >
<sources failonempty="true">
<!--<include name="*.cs"/>-->
<include name="***.cs" />
<include name="/app_code/*.*" />
<include name="/app_data/*.*" />
</sources>

<nowarn>
<warning number="0169" />
<warning number="0436" />
<warning number="0649" />
<warning number="1591" />
<warning number="1701" />
<warning number="1702" />
</nowarn>

<references basedir="${build.dir}">
<include name="System.dll" />
<include name="SystemData.dll" />
</references>

</csc>
</target>

<target name="generate-assembly-info">
<asminfo language="CSharp" output="AssemblyInfo.cs">
<imports>
<!--
<import namespace = "System" />
<import namespace = "System.Data" />
<import namespace = "System.Configuration" />
<import namespace = "System.Web" />
<import namespace = "System.Web.Security" />
<import namespace = "System.Web.UI" />
<import namespace = "System.Web.UI.WebControls" />
<import namespace = "System.Web.UI.WebControls.WebParts" />
<import namespace = "System.Web.UI.HtmlControls" />
-->
</imports>
<attributes>
<!--<attribute type="AssemblyVersionAttribute" value="1.0.0.0"/>-->
</attributes>
</asminfo>
</target>

</project>




Information
========
I'm using NANT version - 0.85.2136.0
Also, I was being told that this works with ASP.NET 2.0 :)
I have tried adding references to all sort of assemblies, all sorts of
folder path, but no luck

Question
=======
Can anybody please tell me what could be the error?

Any help appreciated

Thanks
PP
 
B

Bruce Barker

in version 2.0, web projects are no longer built with csc.exe you must use
the aspnet_compiler.exe instead. i don't think nant has an asp.net compiler
task yet. you will have to use a custom build task.

see the aspnet_compiler.exe switches

on the flip side i have nunit working fine with version 2.0.

-- bruce (sqlwork.com)

Hi Folks

Not sure if this is the right group, if not please re-direct me to the
right one.

Here is my question
===============
When I compile my ASP.NET WEB project from VS 2005 (.NET Framework 2.0)
IDE, it works fine, but if I use NANT (Build Automation) it gives me an
error as follows:

[csc] Starting 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe
(@"C:\Documents and Settings\pprabhu\Local Settings\Temp\tmpDF.tmp")'
in 'C:\xxx\WebSite2'
[csc] c:\xxx\WebSite2\Default.aspx.cs(16,9): error CS0103: The name
'TextBox1' does not exist in the current context

BUILD FAILED

Here is the source code
=================
Default.aspx
~~~~~~~~~
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>

Default.aspx.cs
~~~~~~~~~~~~
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default : System.Web.UI.Page
{
//protected System.Web.UI.WebControls.TextBox TextBox1;
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Text = "Hello World";
}
}

site.build (NANT Build File)
~~~~~~~~~~~~~~~~~~~~
<?xml version="1.0" ?>
<project name="HRRelocproject" default="build">
<property name="project.type.actual" value="exe"/>
<property name="build.dir" value="build" />


<target name="build">
<echo message="'${project.type.actual}'" />
<call target="generate-assembly-info" />

<csc target = "library"
warnaserror = "true"
verbose = "true"
output = "${build.dir}/site.dll" >
<sources failonempty="true">
<!--<include name="*.cs"/>-->
<include name="***.cs" />
<include name="/app_code/*.*" />
<include name="/app_data/*.*" />
</sources>

<nowarn>
<warning number="0169" />
<warning number="0436" />
<warning number="0649" />
<warning number="1591" />
<warning number="1701" />
<warning number="1702" />
</nowarn>

<references basedir="${build.dir}">
<include name="System.dll" />
<include name="SystemData.dll" />
</references>

</csc>
</target>

<target name="generate-assembly-info">
<asminfo language="CSharp" output="AssemblyInfo.cs">
<imports>
<!--
<import namespace = "System" />
<import namespace = "System.Data" />
<import namespace = "System.Configuration" />
<import namespace = "System.Web" />
<import namespace = "System.Web.Security" />
<import namespace = "System.Web.UI" />
<import namespace = "System.Web.UI.WebControls" />
<import namespace = "System.Web.UI.WebControls.WebParts" />
<import namespace = "System.Web.UI.HtmlControls" />
-->
</imports>
<attributes>
<!--<attribute type="AssemblyVersionAttribute" value="1.0.0.0"/>-->
</attributes>
</asminfo>
</target>

</project>




Information
========
I'm using NANT version - 0.85.2136.0
Also, I was being told that this works with ASP.NET 2.0 :)
I have tried adding references to all sort of assemblies, all sorts of
folder path, but no luck

Question
=======
Can anybody please tell me what could be the error?

Any help appreciated

Thanks
PP
 
G

Guest

Finally I found a work around :)

Here is the code changes I made
=====================
Change-1
~~~~~~
Used <exec> insted of <csc>

<target name="build">
<exec program =
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\msbuild.exe"
failonerror = "true"
verbose = "true" >
<arg value="${SolutionFilePathAndName}" />
</exec>
</target>

Change-2
~~~~~~
Added a property, pointing to my Solution File
<property name="SolutionFilePathAndName" value="C:\Projects\HR
Relocation\hrreloc\ui\hrreloc.sln" />

Change-3
~~~~~~
Got rid of rest of the stuff within <target> TAG


Note
===
Change your path for MSBuild.EXE and Solutionfile accordingly, it will work
like a charm

Thanks
PP
Hi Folks

Not sure if this is the right group, if not please re-direct me to the
right one.

Here is my question
===============
When I compile my ASP.NET WEB project from VS 2005 (.NET Framework 2.0)
IDE, it works fine, but if I use NANT (Build Automation) it gives me an
error as follows:

[csc] Starting 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe
(@"C:\Documents and Settings\pprabhu\Local Settings\Temp\tmpDF.tmp")'
in 'C:\xxx\WebSite2'
[csc] c:\xxx\WebSite2\Default.aspx.cs(16,9): error CS0103: The name
'TextBox1' does not exist in the current context

BUILD FAILED

Here is the source code
=================
Default.aspx
~~~~~~~~~
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>

Default.aspx.cs
~~~~~~~~~~~~
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default : System.Web.UI.Page
{
//protected System.Web.UI.WebControls.TextBox TextBox1;
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Text = "Hello World";
}
}

site.build (NANT Build File)
~~~~~~~~~~~~~~~~~~~~
<?xml version="1.0" ?>
<project name="HRRelocproject" default="build">
<property name="project.type.actual" value="exe"/>
<property name="build.dir" value="build" />


<target name="build">
<echo message="'${project.type.actual}'" />
<call target="generate-assembly-info" />

<csc target = "library"
warnaserror = "true"
verbose = "true"
output = "${build.dir}/site.dll" >
<sources failonempty="true">
<!--<include name="*.cs"/>-->
<include name="***.cs" />
<include name="/app_code/*.*" />
<include name="/app_data/*.*" />
</sources>

<nowarn>
<warning number="0169" />
<warning number="0436" />
<warning number="0649" />
<warning number="1591" />
<warning number="1701" />
<warning number="1702" />
</nowarn>

<references basedir="${build.dir}">
<include name="System.dll" />
<include name="SystemData.dll" />
</references>

</csc>
</target>

<target name="generate-assembly-info">
<asminfo language="CSharp" output="AssemblyInfo.cs">
<imports>
<!--
<import namespace = "System" />
<import namespace = "System.Data" />
<import namespace = "System.Configuration" />
<import namespace = "System.Web" />
<import namespace = "System.Web.Security" />
<import namespace = "System.Web.UI" />
<import namespace = "System.Web.UI.WebControls" />
<import namespace = "System.Web.UI.WebControls.WebParts" />
<import namespace = "System.Web.UI.HtmlControls" />
-->
</imports>
<attributes>
<!--<attribute type="AssemblyVersionAttribute" value="1.0.0.0"/>-->
</attributes>
</asminfo>
</target>

</project>




Information
========
I'm using NANT version - 0.85.2136.0
Also, I was being told that this works with ASP.NET 2.0 :)
I have tried adding references to all sort of assemblies, all sorts of
folder path, but no luck

Question
=======
Can anybody please tell me what could be the error?

Any help appreciated

Thanks
PP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top