can not add any other files in addition to DLLs into my MSI build nant file - nant

The following codes work
But this codes gives an error: BUILD FAILED - NESTED BUILD FAILED -Object reference not set to an instance of an object.
<component keepsubdirs="true" name="C__WebConfig"
id="{E2FDCB8C-64AB-4E0A-9FF5-CAF4B940562B}"
attr="0" directory="TARGETDIR" feature="F__WebConfig">
<key file="Web.config" />
<fileset basedir="${Source.Dir}">
<include name="Web.config" />
</fileset>
</component>
Note:
web.config file or any file will not be added to MSI - please help

Related

Error in Target xslt in build.xml for ecllipse

Im trying to include xslt reports in my Testng framework with ant. When I try to execute the the MakeReport target in build.xml I get some error related to classpath saying Reference test.classpath not found . Below is the target code for generating xslt.
<target name="makexsltreport">
<delete dir="${basedir}/testng-xslt">
</delete>
<mkdir dir="${basedir}/testng-xslt">
</mkdir>
<xslt in="${ng.result}/testng-results.xml" style="src/xslt/testng-results.xsl" out="${ws.home}/testng-xslt/index.html"
classpathref="test.c" processor="SaxonLiaison">
<!-- THE ERROR IS IN ABOVE LINE -->
<param expression="${basedir}/testng-xslt/" name="testNgXslt.outputDir" />
<param expression="true" name="testNgXslt.sortTestCaseLinks" />
<param expression="FAIL,SKIP,PASS,CONF,BY_CLASS" name="testNgXslt.testDetailsFilter" />
<param expression="true" name="testNgXslt.showRuntimeTotals" />
<classpath refid="classpath">
</classpath>
</xslt>
</target>
Please help on how to solve this issue. i tried everything.
Reference test.classpath not found
means that Ant wasn't able to find the test.classpath path that you have referenced with classpathref. How are you defining that path? If the <path id="test.classpath"> is inside a target then you will need to make your makexsltreport target depend (directly or indirectly) on the one that defines the path.
Also you should not use both a classpathref attribute and a <classpath> element - use one or the other.

NAnt + Project with GUID must be included

I just started using NAnt today, I followed some of the examples. I am having a hard time with one issue:
Its saying: "Project with GUID '{32845370-6F32-411F-B4C5-383F9C3EDE29}' must be included for
the build to work."
Now I was able to track down the project. Here is my directory structure:
c:\dev\stockclockbuild -> this is where the solution and build file is located.
So I run the command:
nant -buildfile:c:\dev\stockclockbuild\stocks.build
I have a project that it located in c:\dev\_sharedlibs\mdrlibs called "MDR.StockPlatform" which seems to get included, but within that project file I found the project (dependency) that has the GUID mentioned in the error.
That project is called "MDR.Base" but its located in the same folder as MDR.StockPlatform.
Also if I were to open this solution and build it in visual studio it builds without errors.
Here is the complete verbose output:
c:\Dev\_Misc\Tools\nAnt\bin>nant -buildfile:c:\dev\stockclockbuild\stocks.build
NAnt 0.92 (Build 0.92.4543.0; release; 6/9/2012)
Copyright (C) 2001-2012 Gerry Shaw
http://nant.sourceforge.net
Buildfile: file:///c:/dev/stockclockbuild/stocks.build
Target framework: Microsoft .NET Framework 4.0
Target(s) specified: rebuild
clean:
build:
build.stockclock:
[solution] Starting solution build.
[solution] Loading projects...
[solution] Loading project 'c:\dev\stockclockbuild\StockClock.Common\StockClock
.Common.csproj'.
[solution] Using MSBuild version 4.0.30319.1.
[solution] Loading referenced project 'c:\dev\_SharedLibs\MDRLibs\MDR.StockPlat
form\MDR.StockPlatform.csproj'.
BUILD FAILED
Project with GUID '{32845370-6F32-411F-B4C5-383F9C3EDE29}' must be included for
the build to work.
Total time: 0.6 seconds.
Here is a copy of the build file:
<project name="Solution Build Example" default="rebuild">
<property name="configuration" value="release"/>
<target name="clean" description="Delete all previously compiled binaries.">
<delete>
<fileset>
<include name="**/bin/**" />
<include name="**/obj/**" />
<include name="**/*.suo" />
<include name="**/*.user" />
</fileset>
</delete>
</target>
<target name="build" description="Build all targets.">
<call target="build.stockclock"/>
</target>
<target name="rebuild" depends="clean, build" />
<target name="build.stockclock">
<solution configuration="${configuration}" solutionfile="Stockclock.sln" verbose="true">
</solution>
</target>
</project>
I'm assuming you're using a modern IDE, and from the NAnt Documentation:
Note: Right now, only Microsoft Visual Studio .NET 2002 and 2003 solutions and
projects are supported. Support for .NET Compact Framework projects is also not
available at this time.
In my NAnt scripts I use the NauckIT MSBuild task:
<msbuild projectFile="${solution.file}" targets="Build" verbosity="Quiet">
<property name="Configuration" value="${build.configuration}" />
<property name="Platform" value="${build.platform}" />
<arg value="/flp:NoSummary;Verbosity=normal;LogFile=${build.log}" />
<arg value="/p:SignAssembly=true" if="${isReleaseBuild}" />
<arg value="/p:AssemblyOriginatorKeyFile=${solution.keyfile}" if="${isReleaseBuild}" />
<arg value="/p:DelaySign=false" if="${isReleaseBuild}" />
</msbuild>
However that is a personal preference as you could also use the NAnt exec task and call msbuild directly.

How to copy modified files to several servers using ANT

This script works good for the first server (server1), but it doesn't work for the second pass (server2) as at that point all 'modified' files are already flagged by the first pass.
<macrodef name="copythings">
<attribute name="todir"/>
<sequential>
<scp todir="#{todir}" trust="true">
<fileset dir=".">
<modified/>
<include name="cgi-bin/Application/" />
<exclude name="**/*.log" />
</fileset>
</scp>
</sequential>
</macrodef>
<target name="deploy">
<copythings todir="server1"/>
<copythings todir="server2"/>
</target>
I'd suggest copying the files from the fileset to a temporary folder first.
And copy to the server from that directory.
copy required files to a tempory folder
run the targets and use the temporay folder as base/filset for scp
delete the temporary folder

Include/Exclude buildfiles

How do you do this? Given several build files, I only want to include the ones where the target (specified from the command line) exists. Using target::exists in does not seem to work. Thanks.
<target name="*">
<property name="curr.target" value="${target::get-current-target()}"/>
<nant target="${curr.target}">
<buildfiles>
<include name="*.build" if="${target::exists(curr.target)}"/>
<!-- avoid recursive execution of current build file-->
<exclude name="${project::get-buildfile-path()}" />
</buildfiles>
</nant>
</target>
Using robaker's solution, my final build file looks like this. It does not fail anymore if the target is not found in a certain build file (unlike my previous code).
<project>
<include buildfile="A.build"/>
<include buildfile="B.build"/>
<target name="*">
<nant target="${target::get-current-target()}"/>
</target>
</project>
Why not just use the include task to include all your child build scripts instead?

In nant, how to delete contents of a directory, but not the directory itself?

Suppose I were scripting a deployment using nant on a Windows server to a file share: \\server\share. I want a nant script to delete all files from the share then copy in new files.
I have this code to delete the files, but I'm getting an error that it can't delete "\server\share". But I didn't want to delete the share, just the contents in it.
<delete>
<fileset basedir="\\server\share">
<include name="**/**" />
</fileset>
</delete>
Output:
BUILD FAILED
D:\code\xxx\xxx.deploy(177,8):
Cannot delete directory '\\server\share'.
Access to the path '\\server\share' is denied.
If I modified it to instead delete contents of a directory in the share, say \\server\share\somedir, it'll delete "somedir" without error. But still, I didn't want to delete the dir, just the contents. Is there a way?
This works for me - no workarounds required:
<delete>
<fileset basedir="\\server\share">
<include name="**\*" />
</fileset>
</delete>
You could introduce an "exclude" tag and exclude a dummy file. That'll leave the root folder intact.
I'm using the following:
<target name="clean">
<delete>
<fileset basedir="${DeployTo}">
<include name="**/*" />
<exclude name="**/aspnet_client/**" />
</fileset>
</delete>
</target>
Taking cue from nsr81, I was able to come up with this workaround that works for me:
<touch file="${DeployTo}/deleteme" />
<delete>
<fileset basedir="${DeployTo}">
<include name="**/**" />
<exclude name="deleteme" />
</fileset>
</delete>
<delete file="${DeployTo}/deleteme" />