Good day.
I'm trying to deploy a web application using NAnt. It is current zipped using the NAnt ZIP task.
I can try calling MSDeploy from NAnt but I don't think MSDeploy was written for such deployments.
I can also try using NAnt task.
Does anybody have suggestions as to what approach can save me the most time?
Using the aspnet compiler is the simplest way and gets you access to all cl arguments which is not available on nant tasks. Not sure why it's so.
Here's what I do
<property name="aspnetcomplier" value="C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe" />
<target name="deploy">
<mkdir dir="${output.dir}" />
<exec program="${aspnetcomplier}">
<arg value="-v" />
<arg value="/trunk" />
<arg value="-p" />
<arg value="${source.dir}\Root" />
<arg value="-f" />
<arg value="${output.dir}" />
</exec>
</target
Nothing complicated.Works like a charm.
P.S. Dont forget to do a iisreset /stop and /start
<target name="stop.iis" >
<servicecontroller action="Stop" service="w3svc" timeout="10000" verbose="true" />
</target>
<target name="start.iis" >
<servicecontroller action="Start" service="w3svc" timeout="10000" verbose="true" />
</target>
Related
Anyone knows if i could determine if AfterClean task was executed in context of Rebuild.
I am only intrested to execute my task if Clean is executed explicitly from project context menu.
<Target Name="MyTask" AfterTargets="AfterClean">
<Message Text="Removing file: cache.data" Importance="high" />
<Exec Command="del /S cache.data" ></Exec>
</Target>
found answer myself, there may be a better way.
<Target Name="BuildExecutedFlag" BeforeTargets="BeforeRebuild" >
<CreateProperty Value="1">
<Output
TaskParameter="Value"
PropertyName="WasBuildExecuted" />
</CreateProperty>
</Target>
<Target Name="MyTask" AfterTargets="AfterClean" Condition="'$(WasBuildExecuted)' != '1'">
<Message Text="Removing file: cache.data" Importance="high" />
<Exec Command="del /S cache.data" ></Exec>
</Target>
I use Apache Ant project to gather some information about textures. Here you can see a test project that does only reading without any further actions. This is a minimal set that reproduces one nasty bug. I have found that sometimes ImageMagick's identify.exe does not return anything – I've added a code that forces build to fail if so. If I run this project multiple times I will get unstable behavior. Sometimes project build successfully, sometimes it fails with several fail-messages. Developers of ImageMagick say that their tools are thread safe. But if identify.exe is not the case then what can be? I really need help of someone with advance knowledge about Apache Ant and ImageMagick.
<project default="default">
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property name="image_magick_path" location="c:\Program Files\ImageMagick-6.8.9-Q8\"/>
<property name="images_path" location="path\to\folder\with\png\images"/>
<target name="default">
<for param="item" parallel="true">
<path>
<fileset dir="${images_path}">
<patternset id="pattern_images">
<include name="**\*.png"/>
<include name="**\*.jpg"/>
<include name="**\*.gif"/>
<include name="**\*.bmp"/>
</patternset>
</fileset>
</path>
<sequential>
<local name="image_width"/>
<tex_width file="#{item}" property="image_width"/>
<local name="image_height"/>
<tex_width file="#{item}" property="image_height"/>
<if>
<or>
<equals arg1="${image_width}" arg2=""/>
<equals arg1="${image_height}" arg2=""/>
</or>
<then>
<fail message="Got nothing. But why? Image: #{item}"/>
</then>
</if>
</sequential>
</for>
</target>
<macrodef name="tex_width">
<attribute name="file"/>
<attribute name="property"/>
<sequential>
<exec executable="${image_magick_path}\identify.exe" outputproperty="#{property}">
<arg value="-format"/>
<arg value="%w"/>
<arg value="#{file}"/>
</exec>
</sequential>
</macrodef>
<macrodef name="tex_height">
<attribute name="file"/>
<attribute name="property"/>
<sequential>
<exec executable="${image_magick_path}\identify.exe" outputproperty="#{property}">
<arg value="-format"/>
<arg value="%h"/>
<arg value="#{file}"/>
</exec>
</sequential>
</macrodef>
</project>
Ok, I will write here how I managed to solve my problem. I hope it will help someone someday.
First thing I found is that PHP method 'getimagesize' is much faster so I decided to switch to it thus killing the main problem. I wrote following macrodef to get both image width and height:
<macrodef name="getimagesize">
<attribute name="file"/>
<attribute name="propertywidth"/>
<attribute name="propertyheight"/>
<sequential>
<local name="output"/>
<exec executable="php" outputproperty="output">
<arg value="-r"/>
<arg value=
""$size=getimagesize('#{file}');
echo($size[0].' '.$size[1]);""
/>
</exec>
<propertyregex
property="#{propertywidth}"
input="${output}"
regexp="(\d*) (\d*)"
replace="\1"
/>
<propertyregex
property="#{propertyheight}"
input="${output}"
regexp="(\d*) (\d*)"
replace="\2"
/>
</sequential>
</macrodef>
Unfortunately this macrodef has abosutely same bug. Sometimes during parallel run some exec-tasks returned nothing in output. I was very upset so I decided to write another macrodef which I use now and finally it works fine. What I did was avoid reading anything from exec-task's 'stdout' and use tempfile-task instead. Here's final macrodef:
<macrodef name="getimagesize">
<attribute name="file"/>
<attribute name="propertywidth"/>
<attribute name="propertyheight"/>
<sequential>
<local name="file_dirname"/>
<dirname property="file_dirname" file="#{file}"/>
<local name="file_temp"/>
<tempfile property="file_temp" destdir="${file_dirname}" createfile="true"/>
<exec executable="php">
<arg value="-r"/>
<arg value=""$size=getimagesize('#{file}');
file_put_contents('${file_temp}', $size[0].' '.$size[1]);""/>
</exec>
<local name="file_temp_content"/>
<loadfile property="file_temp_content" srcfile="${file_temp}"/>
<delete file="${file_temp}"/>
<propertyregex
property="#{propertywidth}"
input="${file_temp_content}"
regexp="(\d*) (\d*)"
replace="\1"
/>
<propertyregex
property="#{propertyheight}"
input="${file_temp_content}"
regexp="(\d*) (\d*)"
replace="\2"
/>
</sequential>
</macrodef>
I am attempting to merge a Visual Studio 2010 project to 2012. The 2010 solution had a deployment project which output can be replicated by publishing in 2012. Our build script looking something like this:
<target name="buildSolution">
<delete file="${BuildRootFolder}\build.log" />
<exec program="devenv.exe" verbose="true" timeout="2400000"
commandline='/out build.log ${BuildRootFolder}\Solution.sln /Build "Release" /deploy Solution'
basedir="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE">
<environment>
<variable name="PATH"
value="blah blah....">
</environment>
</exec>
</target>
How do I update this to Publish one of the projects in that solution using the publishing profile I defined?
Forget devenv and use msbuild.
<property name="MSBuildPath" value="C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"/>
<target name="buildSolution" depends="clean">
<exec program="${MSBuildPath}">
<arg line='"${BuildRootFolder}\Solution.sln"' />
<arg line='/property:Configuration="Release";DeployOnBuild=true;PublishProfile=Deployment' />
<arg value="/target:Build" />
<arg value="/verbosity:normal" />
<arg value="/nologo" />
</exec>
</target>
My aim is to fill property with output of command "git describe".
I have a property:
<property name="build.version" value = ""/>
And I want to fill it with output of the following command: git describe
I tried:
<exec program='${git.executable}' outputproperty='build.version'>
<arg value='describe' />
</exec>
but unlike the Ant, NAnt doesn't support outputproperty :( only output (to file).
You're right. You have resultproperty attribute to hold the exit code and output attribute to redirect the output.
Why don't you redirect the output and load the file afterwards via loadfile task:
<target name="foo">
<property
name="git.output.file"
value="C:\foo.txt" />
<exec program="${git.executable}" output="${git.output.file}">
<arg value="describe" />
</exec>
<loadfile
file="${git.output.file}"
property="git.output" />
</target>
Using trim, you can get rid of the carriage return character at the end. For instance, in the example above, add a line at the end to trim the string
<target name="foo">
<property
name="git.output.file"
value="C:\foo.txt" />
<exec program="${git.executable}" output="${git.output.file}">
<arg value="describe" />
</exec>
<loadfile
file="${git.output.file}"
property="git.output" />
<property name="git.ouput.trimmed" value="${string::trim(git.output)}" />
</target>
On my development machine I installed VSeWSS 1.3 and configured the local IIS 6 so that I can build my SharePoint project and deploy the generated WSP file to the local machine. The WSP file is generated by the Packaging step, which I can successfully install on other machines.
Now I have to migrate my project to our build machine which currently does not have SharePoint installed and is not configured for VSeWSS (no VSeWSS web service endpoint). Is there a way to automate the building of the WSP file without the need to configure IIS on the build machine for use with SharePoint and VSeWSS?
Some of the books describe the manual step of using MakeCab.exe and defining a DDF file, but I don't see any DDF file generated by VSeWSS (is it maybe generated in a TEMP folder which I could use to configure my automated build process?).
I just faced the same problem. I opted for another tool for developing the whole solution: I found WSPBuilder much cleaner and less intrusive. It also can be used from the Command line, which is great for Build files.
I modified some Nant scripts created by Bil Simser in order to compile and deploy the project and move the code from VSeWSS to WSPBuilder. It works like a charm either on my machine or on the build machine.
You can find WSPBuilder on http://www.Codeplex.com, and these targets need nantContrib (on www.tigris.org) to work.
Here are some of the targets I'm using:
<target name="build" depends="compile">
<copy todir="${build.dir}\12\">
<fileset basedir="${sharepoint.dir}\12">
<include name="**/*"/>
</fileset>
</copy>
<copy
file="${sharepoint.dir}\solutionid.txt"
tofile="${build.dir}\solutionid.txt"
/>
<call target="buildsolutionfile" />
</target>
<target name="buildsolutionfile">
<exec program="${wspbuilder.exe}" workingdir="${build.dir}">
<arg value="-BuildDDF"/>
<arg value="${debug}"/>
<arg value="-Cleanup"/>
<arg value="false"/>
<arg value="-FolderDestination"/>
<arg value="${build.dir}"/>
<arg value="-Outputpath"/>
<arg value="${build.dir}"/>
<arg value="-TraceLevel"/>
<arg value="verbose"/>
</exec>
<copy
file="${build.dir}\${package.file}"
tofile="${solution.dir}\${package.file}"/>
</target>
<target name="addsolution">
<exec program="${stsadm.exe}" verbose="${verbose}">
<arg value="-o" />
<arg value="addsolution" />
<arg value="-filename" />
<arg value="${solution.dir}\${package.file}" />
</exec>
<call target="spwait" />
</target>
<target name="spwait" description="Waits for the timer job to complete.">
<exec program="${stsadm.exe}" verbose="${verbose}">
<arg value="-o" />
<arg value="execadmsvcjobs" />
</exec>
</target>
<target name="app.pool.reset" description="Resets Sharepoint's application pool.">
<iisapppool action="Restart" pool="${apppool}" server="${server}" />
</target>
<target name="deploysolution" depends="addsolution">
<exec program="${stsadm.exe}" workingdir="${build.dir}" verbose="${verbose}">
<arg value="-o" />
<arg value="deploysolution" />
<arg value="-name" />
<arg value="${package.file}" />
<arg value="-immediate" />
<arg value="-allowgacdeployment" />
<arg value="-allcontenturls" />
<arg value="-force" />
</exec>
<call target="spwait" />
<call target="app.pool.reset" />
</target>