Windows > Windows Forms Forums > ClickOnce and Setup & Deployment Projects > Urgent: Mage.exe Issue with -RequiredUpdate
Ask a questionAsk a question
 

AnswerUrgent: Mage.exe Issue with -RequiredUpdate

  • Wednesday, November 15, 2006 3:58 PMmoGun Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi All,

    I want to ensure that whenever the Application Installed through Click Once runs, it would check for updates before starting. Using the Publish wizard and the mageUI.exe this can be set. And the resultant Deployment Mainfest looks like this.

      <deployment install="true" disallowUrlActivation="true" mapFileExtensions="true">
        <subscription>
          <update>
            <beforeApplicationStartup />
          </update>
        </subscription>
        <deploymentProvider codebase="file://server/Test.application" />
      </deployment>

    But when I try to create the deployment manifest manually using mage.exe there seem to be no option to specify this update option. The resultant deployment manifest looks like this.

      <deployment install="true">
        <subscription>
          <update>
            <expiration maximumAge="0" unit="days" />
          </update>
        </subscription>
        <deploymentProvider codebase="file://server/Test.application" />
      </deployment>

    After checking MSDN, i found this piece of gem hidden in a documentation. The link is

    http://msdn2.microsoft.com/en-us/library/acz3y3te(VS.80).aspx

    And the documentation for "-I, -Install" command line parameter goes like this:

    "(Deployment manifests only) Indicates whether or not the ClickOnce application should install onto the local machine, or whether it should run from the Web. Installing an application gives that application a presence in the Windows Start menu. Valid values are "true" or "t", and "false" or "f". If unspecified, the default value is “true”.

    If you specify the –RequiredUpdate option, it will force the application to install, regardless of the value you pass to -Install."

    But mage.exe doesnot accept the -RequiredUpdate option.

    So i am not sure about how to ensure that my application will look for update before starting.

    Can someone tell me whether i am on the right track? One option is to edit the deployment manifest xml before signing. But thats not a correct solution. Am i missing something here? Can some one throw light on this.

    Appreciate your help. Thanks

    Mohan

     

     


     

     

     

Answers

  • Thursday, December 14, 2006 12:28 AMKent BoogaartMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi moGun,

    I had this same problem today and solved it by replacing the generated expiration element with a beforeApplicationStartup element. I used the community MSBuild tasks in the process (RegexReplace):

    <!-- mage.exe does not allow us to set the update as we'd like so we replace it here -->
    <
    ReadLinesFromFile File='@(DepManifest)'>
        <
    Output TaskParameter="Lines" ItemName="Lines"/>
    </
    ReadLinesFromFile>
    <
    RegexReplace Input='@(Lines)'
            Expression='expiration maximumAge="0" unit="days"'
            Replacement='beforeApplicationStartup '
            Options='Multiline'>
        <
    Output ItemName='ModifiedLines' TaskParameter='Output'/>
    </
    RegexReplace>
    <
    WriteLinesToFile File='@(DepManifest)' Lines='@(ModifiedLines)' Overwrite='true'/>

    Hope that helps,
    Kent Boogaart

All Replies

  • Wednesday, November 15, 2006 5:40 PMLeonid B Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    You should set the version and the minimum required version for the deployment manifest to force users to get updates.

    I use mage to update an existing manifest created by msbuild, and I had to set -v and -mv parameters to make the autoupdates work.

    Leonid

     

  • Wednesday, November 15, 2006 7:20 PMmoGun Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi Leonid,

    May be i didn't explain the issue completly.

    After the installation, the shortcut gets added to the program file. When the this shortcut is clicked, the application should always check if there is new updates. This is controlled by the <update> tag in the Application deployment manifest. When you create this file using mage.exe, the <update> tag is not set to

        <update>
            <beforeApplicationStartup />
          </update>

    Its always set to

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

    There seem to be no way to control this using the mage.exe.

    The documentation of mage.exe doesn't provide any command line parameter to set this.

    I tried the minium version, but it doesn't work.

    Thanks

    Mohan

     

     

     

  • Thursday, November 16, 2006 12:27 AMmoGun Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi,

    I have some more information regarding this.

    I was looking at the code for mage.exe.

    The code for Generating Deployment Manifest sets the updatemode like this:

          if (install == TriStateBool.True)
          {
                manifest1.Install = true;
                manifest1.UpdateEnabled = true;
                manifest1.UpdateMode = UpdateMode.Background;
          }
          else
          {
                manifest1.Install = false;
          }

    So at this point the update mode is set to BackGround. There is no option to specify from the command line argument for mage.exe that the Updatemode is foreground.

    I went further and checked how this Deployment Manifest object gets convereted to the XML i posted in my question. The Microsoft.Build.Tasks.dll is used for all the manifest generation by the mage.exe. With in the Microsoft.Build.Tasks.dll, there exists an XSL file that is used to transform the Deployment XML. It has code like this:

               <subscription>
                    <update>
                        <xsl:choose>
                            <xsl:when test="@UpdateMode='Foreground'">
                                <beforeApplicationStartup/>
                            </xsl:when>
                            <xsl:otherwise>
                                <expiration maximumAge="{@UpdateInterval}" unit="{@UpdateUnit}"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </update>
                </subscription>

    This XSL ensures that the "beforeApplicationStartup" tag is set only if the the update mode is foreground. There is no way i can beat this system. :)

    So finally i end up with a huge loss of time. Now i will have to figure out some other method that suits my purpose to create the deployment manifest with out using mage.exe.

    Is any one from Microsoft Listening? Is there any way that i can make mage.exe do what i want?

    Cheers

    Mohan

     

     

     

     

     

  • Monday, November 20, 2006 3:00 PMmoGun Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    No info from any one else out there... :(

     

  • Thursday, December 14, 2006 12:28 AMKent BoogaartMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi moGun,

    I had this same problem today and solved it by replacing the generated expiration element with a beforeApplicationStartup element. I used the community MSBuild tasks in the process (RegexReplace):

    <!-- mage.exe does not allow us to set the update as we'd like so we replace it here -->
    <
    ReadLinesFromFile File='@(DepManifest)'>
        <
    Output TaskParameter="Lines" ItemName="Lines"/>
    </
    ReadLinesFromFile>
    <
    RegexReplace Input='@(Lines)'
            Expression='expiration maximumAge="0" unit="days"'
            Replacement='beforeApplicationStartup '
            Options='Multiline'>
        <
    Output ItemName='ModifiedLines' TaskParameter='Output'/>
    </
    RegexReplace>
    <
    WriteLinesToFile File='@(DepManifest)' Lines='@(ModifiedLines)' Overwrite='true'/>

    Hope that helps,
    Kent Boogaart

  • Thursday, January 11, 2007 4:28 PMmoGun Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    Hi Kent,

    Thanks for your reply.

    I used the GenereateDeployment Task to overcome this issue in the build script.

    <GenerateDeploymentManifest

    AssemblyName="$(AppName)"

    AssemblyVersion="$(PublishVersion)"

    EntryPoint="$(PublishVersion)\$(AppName).exe.manifest"

    Install="true"

    UpdateEnabled="true"

    UpdateMode="Foreground"

    OutputManifest="$(AppName).application"

    DeploymentUrl="$(PublishRootDir)\$(AppName).application"

    DisallowUrlActivation="true"

    >

     

  • Thursday, January 11, 2007 10:24 PMKent BoogaartMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Thanks moGun. I tried the built-in MSBuild tasks first but could not even get them to generate valid manifests for me. Hence, I switched to mage.exe and found I couldn't set the update mode. Maybe I'll revisit this later. Thanks for the update.

    Regards,
    Kent

  • Thursday, March 27, 2008 5:30 PMpcusters Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Must I only replace the code in de manifest file with your code? Or how does it work?