Use nant to build a custom nant task - nant

I'm using nant to build our product and have written a custom task to notify our helpdesk system that a new build is available.
I've used nant to build the custom task and also to copy the custom nant task assembly into the nant folder so it's loaded automatically.
Worked fine the first time I ran the build.
The second time I ran the build the copy task failed because nant has loaded the custom task assembly and locked the file. Grrr.
How can I get this to work?

You don't need to copy the assembly to the NAnt folder, just place the following at the top of your build script:
<loadtasks assembly="path\to\MyAssembly.dll" />

Related

automatic build and deploy fails with build failure on jazzhub

I am trying to use the feature of jazzhub (IBM DevOps offerings) of automatically build and deploy on Bluemix. I have used Eclipse plugin for Jazzhub to check in my code to my project. However automatic build always fails with the below type of error.
using .gitcredentials to set credentials
Checking out Revision a0b1e7c78b02e82ad210bc369cdd633212cb544f (origin/master)
First time build. Skipping changelog.
[47f4a135-016e-4a75-bb42-f9a9fda6df05] $ /bin/bash /tmp/hudson3124921405781328608.sh
Buildfile: build.xml does not exist!
Build failed
Build step 'Execute shell' marked build as failure
Connecting to https://P90JEN01.sl.jazz.net:9444*
I am able to build and deploy the same code base from Eclipse directly to bluemix. My understanding is that DevOps service create build.xml file automatically if It does not find one. The document says it
"A project relative path where the build scripts are found and executed. The project root will be used if empty. A default build script (e.g., Ant build.xml file or Grunt Gruntfile.js file) will be generated and delivered to your source control system if one is not found. You may need to edit the generated build script to fit your needs".
Can anyone help me here? how to get pass this error and make a build successfully deployed ?
I believe we may need to create build.xml if you are using ant script:
http://thoughtsoncloud.com/2014/10/create-deploy-stand-alone-java-application-ibm-bluemix/
"The next step is to create the script to build the code. In this example, I created an .ant script. You can write in the language of your choice from the options supported in Bluemix. Create a file named build.xml and write the .ant build script."

ScriptSharp compilation with NAnt script

We've recently added the excellent script# to our project. Currently we have it so that our VS build simply copies the compiled .js file from the output directory to the scripts directory of our web app.
We've decided to make it a permanent feature and so would like to make it so that the .js file gets generated as part of our web build NAnt script to ensure that it's always up to date. Is there any way to do this nicely or do I need to call MSBuild from my NAnt script specifying the .csproj file to run the compilation?
Thanks
Stu
This isn't likely the full answer (given I don't have experience with NAnt), but I'll offer it anyway, as it may help.
A script# csproj is very much like any other csproj relying on msbuild. If you've got some way to integrate other msbuild projects into your NAnt build script, the same model should ideally apply to script# projects as well.
In the version of script# that is in the github repository, a web project can add a reference to a script# project (thereby becoming dependent on the script# project), and include an msbuild deploy task, that will copy over scripts from the built script# project into the web project. You can see this in action in the Todo sample (https://github.com/nikhilk/scriptsharp/tree/cc/samples/Todo)

Call custom tool from TFS build

We are using TFS2010 for our web sites's builds and we're in the process of creating fully automated builds. At the moment the sites are built and deployed in remote servers.
The sites contains several configuration files that we would like to transform as part of the build. As there are some rules to create the correct config files we would like to use a custom tool for that purpose (.exe), not to use xml transformations for it.
From what we can see in the build template, MSBuild copies the files to a drop folder and then pushes them to the remote IIS site. We would like to hook our custom tool to this process and do the transformations in the build server before the site is published. The problem is that the MSBuild task is a single node in the build template and we can't find a place where to invoke our tool. Before the MSBuild step, there is no code deployed to the drop folder, after the MSBuild step the code was already deployed to the remote server.
Any ideas on how to plug the custom tool in the correct workflow step?
What is the msbuild target, that you use? I think you can define your own target in csproj file to do the following:
execute your custom tool against required files
run usual build target (or whatever target you normally use)
Edit
E.g. in a .csproj file you could define the following:
<Target Name="buildWithCustomTool">
<!-- Exec your custom tool -->
<Exec Command="your command" />
<!-- Call the build target which will run as normally -->
<CallTarget Targets="Build" />
</Target>
Hope it helps,
Ivan

Is there CI server software that can do all of this?

I'm trying to put together a Continuous Integration server that will do the following:
Work with subversion
Use NUnit tests (fail build on failed tests)
Use partcover (fail build on < X% coverage)
Run code against FxCop (fail build on FxCop warnings, given settings)
Run code against StyleCop (fail build on StyleCop warnings, given settings)
Not as important:
Be able to run from a sln file
Be able to publish the application (ClickOnce is setup for the project already)
I'm using TeamCity right now and it doesn't seem to do 3 or 5, and it doesn't have a runner for the newest NUnit.
From the list of plugins that hudson has, it looks like it can do all of these except 3 (and the not as important requests). I've considered writing a plugin for hudons to use partcover, but that's adding more time to setting up a build server.
NAnt can be used as a build script which will build your projects and then execute NUnit and FXCop.
Another option, which is what I use at work, is create a build script for MSBuild and use the MSBuild Community Tasks which support running FXCop & NUnit among other things.
So for my setup CCNet pulls down the source from SVN then calls MSBuild with the main build file. Inside there it builds the projects, runs NUnit, NCover, FXCop, StyleCop etc. and merges the results which are then displayed on the CCNet webpage. Each task can also be set so if there's a failure the build fails.
I haven't used TeamCity but there should be a way to pull down the source and then run an MSBuild or NAnt build script which will then handle the build steps.
It's not a continuous integration server if it's run from a sln file. Perhaps you're mixing build tool and continuous integration. Many CI servers today does nothing but run build scripts made for other tools like NAnt or Maven. Look at NAnt first if it's what you're looking for. NAnt is able to do the build and execute other tools like FXCop (using NAntContrib library). You use CI server to run a build script on a regular basis.

Using TFS, want to run a command line tool to perform obfuscation

First time using team explorer, and I want to add a build task that will run a command line tool to obfuscate the assembly. This will one of the last tasks to be performed I assume.
How would I go about doing this using Team Explorer?
We use Xenocode Postbuild. To obfuscate, we use a custom build task we wrote in a DLL that we call from the build configuration in TFS.
So we created a custom task that wraps the PostBuild command-line. We pass that task variables from an MSBUILD target. That target is part of the project file associated with our release build definition.