473,216 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,216 software developers and data experts.

building c# with ant or nant

So I have compiled a .dll file from a Visual Studio 2005 project
containing a few dozen c# files. Now I want to automate this build using
ant (have not yet looked at nant, but the rest of my complex build is done
with plain ant). Could someone point me to any tutorial or other guide for
doing this? I would even settle for just how to do it from a command-line.
Jul 6 '06 #1
12 18736
http://www.baccoubonneville.com/blog.../nant-tutorial

I would also recommend Expert .NET Delivery using Nant.

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung

"michael sorens" <m_********@community.nospamwrote in message
news:op***************@spo-cont-2-dt.itron.com...
So I have compiled a .dll file from a Visual Studio 2005 project
containing a few dozen c# files. Now I want to automate this build using
ant (have not yet looked at nant, but the rest of my complex build is done
with plain ant). Could someone point me to any tutorial or other guide for
doing this? I would even settle for just how to do it from a command-line.

Jul 7 '06 #2
Thanks Greg for your informative input.

Hi Michael,

Thank you for your post.

Besides Greg's suggestion on using NAnt, you can use ANT to build VS2005
project:

#ANT .NET Tasks
http://ant.apache.org/manual/OptionalTasks/dotnet.html
You can use "Csc" task to build your C# project, but it requires you to
re-specify included C# source files and referenced libraries.

Another option is to use ANT Exec task
(http://ant.apache.org/manual/CoreTasks/exec.html) to call Devenv.exe:

#Devenv Command Line Switches
http://msdn2.microsoft.com/en-us/library/xee0c8y7.aspx
You can use "/Build" switch to build an existing Visual Studio 2005
solution or project.

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 7 '06 #3
Thanks Walter. These are good documentation pointers. From your
information, I observe that while the DotNet tasks in ant provide "native"
support in a sense, they require one to specify the architecture of the
build, which is already available in the solution file. So adhering to the
Good Programming Practice of laziness, it looks like using the ant exec
task to invoke devenv, which can directly use the solution file, would be
the simplest to implement.

On Fri, 07 Jul 2006 01:19:19 -0700, Walter Wang [MSFT]
<wa****@online.microsoft.comwrote:
Thanks Greg for your informative input.

Hi Michael,

Thank you for your post.

Besides Greg's suggestion on using NAnt, you can use ANT to build VS2005
project:

#ANT .NET Tasks
http://ant.apache.org/manual/OptionalTasks/dotnet.html
You can use "Csc" task to build your C# project, but it requires you to
re-specify included C# source files and referenced libraries.

Another option is to use ANT Exec task
(http://ant.apache.org/manual/CoreTasks/exec.html) to call Devenv.exe:

#Devenv Command Line Switches
http://msdn2.microsoft.com/en-us/library/xee0c8y7.aspx
You can use "/Build" switch to build an existing Visual Studio 2005
solution or project.

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.
Jul 7 '06 #4
Hi Michael,

Thank you for your quick reply.

After written my last post, I've done some more research on this.

While directly executing Devenv.exe is simplest, it does have two
drawbacks:
1) The overhead cost of running Visual Studio 2005 is quite large;
2) Not all machines that need to build the project will have Visual Studio
2005 installed.

If this concerns you, I recommend you to use NAnt, it has a task named
<solutionwhich can process a given solution file and compile the projects
contained within. It recognizes inter-project dependencies and compiles
them in the correct order. And it does not invoke devenv.exe, but rather
parses the solution file and invokes the command-line compiler. You can
find more information here:

#Managing .NET Development with NAnt
http://www.theserverside.net/tt/arti...le.tss?id=NAnt

#NAnt task: <solution>
http://nant.sourceforge.net/release/.../solution.html

Since you've already written your ANT build file, you can only create a
simple NAnt build file for your Visual Studio 2005 project and call NAnt
from ANT.

Hope this helps. Please feel free to post here if anything is unclear.

--
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Jul 7 '06 #5

Walter Wang [MSFT] wrote:
Hi Michael,

Thank you for your quick reply.

After written my last post, I've done some more research on this.

While directly executing Devenv.exe is simplest, it does have two
drawbacks:
1) The overhead cost of running Visual Studio 2005 is quite large;
2) Not all machines that need to build the project will have Visual Studio
2005 installed.

If this concerns you, I recommend you to use NAnt, it has a task named
<solutionwhich can process a given solution file and compile the projects
contained within. It recognizes inter-project dependencies and compiles
them in the correct order. And it does not invoke devenv.exe, but rather
parses the solution file and invokes the command-line compiler. You can
find more information here:

#Managing .NET Development with NAnt
http://www.theserverside.net/tt/arti...le.tss?id=NAnt

#NAnt task: <solution>
http://nant.sourceforge.net/release/.../solution.html

Since you've already written your ANT build file, you can only create a
simple NAnt build file for your Visual Studio 2005 project and call NAnt
from ANT.
Since this discussion is about VS2005 (which I'm not using yet, so I
have no firsthand experience), I'm surprised that nobody has yet
mentioned MSBuild. Isn't MSBuild based on the same principles as Ant
and NAnt? Is there no way to invoke MSBuild from Ant, rather than
firing up the entire Visual Studio just to do a build?

Jul 7 '06 #6
Walter Wang [MSFT] wrote:
If this concerns you, I recommend you to use NAnt, it has a task named
<solutionwhich can process a given solution file and compile the projects
contained within.
As far as I remember, NAnts <solutiontask doesn't support VS2005 yet.
I haven't tried it with the latest version, but the docs still say the same.

Max
Jul 8 '06 #7
My mistake, Thanks Max for pointing out. The latest NAnt version's
<solutiontask currently still only supports VS2002 and VS2003 yet. Sorry
for the confusion.

--
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Jul 8 '06 #8
Thanks Bruce for your input.

I should have mentioned that MSBuild can be used to build VS2005 solution
or project files without Visual Studio 2005 installed. Normally you can
find MSBuild.exe at %windir%\Microsoft.NET\Framework\<v2_version>.

#MSBuild Command Line Reference
http://msdn2.microsoft.com/en-us/library/ms164311.aspx

--
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Jul 8 '06 #9
Thanks, Walter, for mentioning the overhead of devenv; that is significant.
So if NANT does not yet support VS2005, then am I correctly inferring that
the msbuild suggestion (invoking in ant via exec task) would be able to use
the solution file and avoid the overhead of firing up VS?
Jul 8 '06 #10
Hi Michael,

Thank you for your update.

Actually MSBuild is included in .NET Framework 2.0 Redistribution Package
and runs without Visual Studio 2005. It can build VS2005 solution or
project files out of the box.

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 10 '06 #11
Yes, I understood from the thread that MSBuild does not need VS2005. I was
getting back to my original question--integrating a build of a VS Project
into an existing Ant build. And what I last inquired about I have now
implemented. That is, all it took was a couple lines in my ant file doing
an <exectask with msbuild and my project file. I observe that msbuild
does handle conditional rebuild as well, so I did not have to add any
conditionals in ant.

[
If you are curious, here are two different snapshots of the build process
I use for my open-source web site and download libraries, auto-generated
from the ant file; the pictures show my C# documentation step but not the
C# compile step just discussed.
http://cleancode.sourceforge.net/arch/ant/ant_all.png
http://cleancode.sourceforge.net/arch/ant/build.png
]

The msbuild tool seems very much like ant or nant; assuming nant came
after msbuild, I am wondering what msbuild is lacking that drove the need
for nant?
Jul 10 '06 #12
michael sorens wrote:
The msbuild tool seems very much like ant or nant; assuming nant came
after msbuild, I am wondering what msbuild is lacking that drove the need
for nant?
You have the chronological order backward. NAnt was built to address
the lack of a build system for .NET outside of the Visual Studio
environment. Microsoft cribbed from NAnt (says me) and came out with
MSBuild only in the VS2005 release (.NET 2.0).

So NAnt predates MSBuild.

Jul 10 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: HaukiDog | last post by:
Hi, I am trying to set up my C# web project to be compiled by NANT. Everything compiles and works fine within the IDE. I have a created a NANT build file which has a simple project tag, like...
1
by: Mikkel Faarup | last post by:
Hi All I have run into a problem using NANT. When building with NANT and local characters like are used in file- and method-names NANT reports an XMLParser error? VS.Net builds fine...
1
by: Chua Wen Ching | last post by:
Hi there, I try to find on the internet on how to achieve this, but still can't find any good resources till i downloaded Nant. But there are too many codes inside Nant, and i have no idea...
3
by: Me | last post by:
I have a simple solution file which I am looking to build using Nant However this is written in .net 2.0 and when I try building this .net 2.0, I get an error message saying "Microsoft Visual...
4
by: SenthilVel | last post by:
Hi I am in a conversion project of Code from .Net 1.1 -->.Net 2.0 . 1. I am going to build all my projects with NAnt RC4 version and also with VS2005 to check the affected Areas. 2. I have...
1
by: jamesmcdonagh | last post by:
Hi newbie using nAnt for .net 2.0. I would be happy of any help that you may be able to provide. The weird thing is that VS.net builds without a problem. And the intellisense within the object...
1
by: Crash | last post by:
Hi all, Is there a newsgroup for NANT? Or is there some place I can post NANT questions? In case this newsgroup is Ok for NANT questions, here is my issue: Windows XP VS 2003
4
by: ramshankaryadav | last post by:
Hi, I'm facing a problem while building a project through MSBuild, this project is a part of a solution which has several other projects on which it depends, but I want to build this project...
11
by: Mike Schilling | last post by:
I recently installed the .NET 3.0 framework (behind the time, I know), and am seeing an issue building it. Because 3.0 doesn't upgrade csc.exe, I'm still using the 2.0 csc to build things. ...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.