Hi!

I often face the problem of synchronizing Visual Studio (both 2003 and 
2005 versions) projects with NAnt. I usually build with NAnt but want to 
provide Visual Studio build files for my users. The problem is that I 
tend to forget to update all the projects (*.csproj) with the newly 
files or to remove the files that are no longer in my source directory.

I wrote a small task for NAnt, called "sync-vs-project-items" that takes 
care of all the synchronization necessary. It adds/removes files in VS 
Project until they are in sync with the directory.

I'm currently hosting this task in the NLog Project's repository, but if 
there's any interest I can make a separate release. Feel free to include 
it in NAntContrib, if you like. The license is BSD.

Grab the source code at:

http://svn.nlog-project.org/repos/nlog/trunk/NLog/tools/SyncVSProjectItems.cs

As you can see below, a single execution of the task lets you update all 
matching project files.

Usage:

<!-- compile NAnt task -->
<csc target="library" output="build/SyncVSProjectItems.dll">
    <sources basedir="tools">
        <include name="SyncVSProjectItems.cs" />
    </sources>
    <references>
        <include name="${nant::get-base-directory()}/NAnt.Core.dll" />
    </references>
</csc>

 <!-- load newly compiled NAnt task -->
 
<loadtasks assembly="build/SyncVSProjectItems.dll" />

 <!-- synchronize NLog.csproj, NLog-net-2.0.csproj and NLog.csdproj -->

<sync-vs-project-items>
    <project-files basedir="src/NLog">
        <include name="*.csproj" />
        <include name="*.csdproj" />
    </project-files>
    <source-files basedir="src/NLog">
        <include name="**/*.cs" />
    </source-files>
</sync-vs-project-items>

 <!-- synchronize NLog-net-2.0.csproj, NLog.ComInterop-net-2.0.csproj-->

<sync-vs-project-items>
    <project-files basedir="src/NLog.ComInterop">
        <include name="*.csproj" />
        <include name="*.csdproj" />
    </project-files>
    <source-files basedir="src/NLog.ComInterop">
        <include name="**/*.cs" />
    </source-files>
</sync-vs-project-items>

The task seems to support C#/VB projects in Visual Studio 2003/2005, but 
should also support VS.NET 2002 (unchecked).
If you find any bugs, report them to me or to the NLog mailing list:

http://www.nlog-project.org/mailinglists.html

-- 

Jarek Kowalski
http://blog.jkowalski.net
http://www.nlog-project.org/ - A .NET Logging Library




-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to