NAant ClickOnce deployment script and minimum required version?


  • Hi!

    I have an application (developet in VS2005 .NET Framework 2.0) for which I have created a deployment script using NAant. It works like a charm except for one thing, I need to force the user to update the application once a new version is avaliable. I just don't seem to be able to achive this?! Below you can see the script:

    I have noticed when I examine the Application.application that the update tag looks like this:

      <expiration maximumAge="0" unit="days" />

    instead of

      <beforeApplicationStartup />

    which is the case if I generate the ClickOnce-deployment from VisualStudio.

    Also the deployment tag looks different. The Application.application file contains this:

    <deployment install="true">

    While the VS2005 generated file contains this:

    <deployment install="true" minimumRequiredVersion="x.x.x.x" />

    What do I need to change to make it work? (I have used the mage.exe supplied with VS2008, mage.exe for VS2005 somehow didn't work)

    Thanks in advance!


    <?xml version="1.0"?>
    <project name="Application" default="publish">
    	<!-- Set .NET Framework 2.0 to match the version of Application. -->
    	<echo message="Setting current .NET Framework to version .NET 2.0." />
    	<property name="nant.settings.currentframework" value="net-2.0" />	
    	<target name="publish">
    		<!-- Setting variables containing all directories necessary. -->
    		<property name="build.dir" value="C:\DATA\Dev\Application\Application\bin\Debug" />
    		<property name="build.file" value="${build.dir}\Application.exe" />
    		<property name="Deployment.dir" value="C:\DATA\Dev\ClickOnceDeployment" />
    		<property name="publish.version" value="${script::get-file-version(build.file)}" />
    		<property name="publish.url" value="C:\DATA\Dev\Click\publish" />
    		<echo message="Publishing version ${publish.version} of Application" />
    		<!-- Copy all the files to the deploy folder -->
    		<echo message="Copying Application files from ${build.dir} to $${Deployment.dir}\${publish.version}." />
    		<delete dir="${Deployment.dir}\${publish.version}" failonerror="false" />
    		<mkdir dir="${Deployment.dir}\${publish.version}" />
    		<copy todir="${Deployment.dir}\${publish.version}" overwrite="true" includeemptydirs="true" >
    			<fileset basedir="${build.dir}">
    				<includes name="**" />
    		<!-- Creating Application Manifest -->
    		<echo message="Creating application manifest ${Deployment.dir}\${publish.version}\Application.exe.manifest." />
    		<exec program="mage" commandline="-New Application -t ${Deployment.dir}\${publish.version}\Application.exe.manifest -fd ${build.dir} -Name Application -Version ${publish.version}" />
    		<exec program="mage" commandline="-Sign ${Deployment.dir}\${publish.version}\Application.exe.manifest -CertFile Application.pfx -Password application_password" />
    		<!-- Creating Deployment Manifest -->
    		<echo message="Creating deployment manifest ${Deployment.dir}\${publish.version}\Application.exe.manifest." />		
    		<exec program="mage" commandline='-New Deployment -t ${Deployment.dir}\Application.application -pu ${publish.url}\Application.application -Name Application -install true -appm ${Deployment.dir}\${publish.version}\Application.exe.manifest -Version ${publish.version}' />
    		<exec program="mage" commandline="-Update ${Deployment.dir}\Application.application -MinVersion ${publish.version} -UseManifestForTrust true -Publisher MyCompany" />
    		<exec program="mage" commandline="-Sign ${Deployment.dir}\Application.application -CertFile Application.pfx -Password application_password" />
    	<!-- *****************************************************************************************-->
    	<!-- Script extracting the file version of a file which path and name is an in parameter to  -->
    	<!-- this function.																			 -->
    	<!-- *****************************************************************************************-->
    	<script language="C#" prefix="script">
    			<import namespace="System.Diagnostics" />
    			<include name="c:\windows\\framework\v2.0.50727\system.dll" />
    				public string GetFileVersion( string file ) 
    					System.Diagnostics.FileVersionInfo myFileVersionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(file);
    					return myFileVersionInfo.FileVersion;

    • Moved by Victor_Chen Thursday, October 21, 2010 9:32 AM clickonce and deployment (From:MSBuild)
    Wednesday, October 20, 2010 9:28 AM

All replies

  • Hi Sekarmaeu,


    Thanks for your post.

    I think this issue is more relevant to Clickonce and deployment. I'm going to move it.

    Hope you can get more helpful information there.


    Best Regards,

    Ziwei Chen




    Thursday, October 21, 2010 9:31 AM

    This isn't something that can be changed using Mage. I am not familiar with NAant, but it's probably a wrapper around the mage tool provided by Microsoft.


    Click here to visit my ClickOnce blog!
    Microsoft MVP, Client App Dev
    Sunday, October 24, 2010 6:17 AM