BTDF / DeploymentFramework

The Deployment Framework for BizTalk is the most powerful and customizable, yet easy-to-use toolkit for deploying and configuring your BizTalk solutions.
MIT License
53 stars 24 forks source link

BTDF 6: Shortcut arguments too long #360

Open tfabraham opened 6 years ago

tfabraham commented 6 years ago

hi, since the bat files for deploy/undeploy... are dropped in favor of shortcuts, which i dearly appreciated at first glance, we had quite the problem to make them work. all paths are provided full qualified and therefore can potentially be quite long - too long for shortcut arguments which are limited to 260 chars (and the rest is simply cut off without mentioning). in our environment some properties were not provided to the msbuild call leading to unexpected results.

our workaround was to shorten the argument list by putting some of the needed properties in the msbuild calls in serverexecute.targets file. an ugly solution since we did not want to modify the original files to prevent messing around again and again when updating.

yes we could have used good'ol'bat-files instead but i like the idea of creating shortcuts, so pls look into this and maybe there is a (clean) way to shorten the paths/arguments? greetings alex

This work item was migrated from CodePlex

CodePlex work item ID: '10775' Vote count: '1'

tfabraham commented 6 years ago

[tfabraham@11/6/2014] Hi Alex, I need some more context, because by default there is nothing in the paths that is very long. Are you modifying the WiX build to add your own properties to the shortcut commands?

tfabraham commented 6 years ago

[getstoopid@11/10/2014] yes there is... and yes i do ;) but now that i read it again i see that i made a mistake which probably lead to your confusion - the property "Target" of a shortcut is limited to 260 chars - meaning the whole and complete call. the problem here is that it starts with the full qualified path to UacElevate which potentially can be long... or even longer ;)

i modified the xslt file by adding a new shortcut element to uninstall the biztalk solution (undeploy and uninstall msi). in this entry i provide the product id as parameter so that i'm able to call msiexec /x after undeployment. in my first test nothing happend - it wouldn't event start the undeploy process. after playing around a bit with the order of the parameters i finally saw what happened - my parameters where cut-off and when the target came after the product id nothing happened since there now was no entry point to start from...

this is what my shortcut looks like (default, no modification) _"{Path_to_installedapplication}\Deployment\Framework\DeployTools\UacElevate.exe" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" "/p:Configuration=Server /t:LaunchServerDeployWizard /clp:NoSummary;DisableMPLo <- missing parts "gging /tv:4.0"

the path to uacelevate.exe is about 120 chars long i was stunned that it even started since the last " are missing also...

tfabraham commented 6 years ago

[tfabraham@11/11/2014] The ProductID property is available at all times in your .btdfproj, so you could just add a new Target in the .btdfproj that references the ProductID property, and call that target from your custom shortcut. I don't see a need to pass ProductID via the command line in the shortcut.

One comment on the process -- it seems like you have a file locking issue because if MSBuild is launching the uninstall, then by definition the MSBuild targets/btdfproj are in use by MSBuild and can't be removed by Windows Installer.

tfabraham commented 6 years ago

[getstoopid@11/14/2014]

...it seems like you have a file locking issue because if MSBuild is launching the uninstall, then by definition the MSBuild targets/btdfproj are in use...

hmmm had no problems so far but what you are saying sounds plausible. so thanks, i will look into it. haven't thought about that until now since it just worked. need to find out why actually...

but you are missing my point! the reason i posted this issue is not because i have or had problems with my customizations but because the shortcut is (in most environments) too long by default and cut-off anywhere in the middle of the string what could lead to unexpected and undesired behavior. actually in the meantime i had an environment where i could not deploy my packed solution because of a broken shortcut. since i did know this issue i knew immediately why this happened (namely nothing in this particular situation) and could simply fix it manually in a few seconds.

you use a xslt transformation for the uacelevate.exe

<xsl:template match="wix:File[contains(@Source,'UacElevate.exe')]">
      <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
        <xsl:processing-instruction name="if">$(var.CreateStartMenuShortcuts) ~= True</xsl:processing-instruction>
        <xsl:element name="Shortcut">
          <xsl:attribute name="Id">DeployShortcut</xsl:attribute>
          <xsl:attribute name="Directory">BizShortCuts</xsl:attribute>
          <xsl:attribute name="Name">Deploy $(var.PackageDescription)</xsl:attribute>
          <xsl:attribute name="Arguments">&quot;[MSBUILDPATH]&quot; &quot;/p:Configuration=Server /t:LaunchServerDeployWizard /clp:NoSummary;DisableMPLogging $(var.ProjectFilename) [MSBUILDTOOLSVER]&quot;</xsl:attribute>
          <xsl:attribute name="WorkingDirectory">DEPLOYMENTDIR</xsl:attribute>
          <xsl:attribute name="Advertise">yes</xsl:attribute>
        </xsl:element>

this transformation should generate a shortcut like so (i guess) _"C:\abc.com\BizTalk\Deployments\abc.biztalk.application_BTDFTest 1.0.0.0\Deployment\Framework\DeployTools\UacElevate.exe" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" "/p:Configuration=Server /t:LaunchServerDeployWizard /clp:NoSummary;DisableMPLogging C:\abc.com\BizTalk\Deployments\abc.biztalk.applicationBTDFTest 1.0.0.0\Deployment\Deployment.btdfproj /tv:4.0"

and this is what gets generated (what i see when i open properties->shortcut->target on lnk file) _"C:\abc.com\BizTalk\Deployments\abc.biztalk.applicationBTDFTest 1.0.0.0\Deployment\Framework\DeployTools\UacElevate.exe" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" "/p:Configuration=Server /t:LaunchServerDeployWizard /clp:NoSummary;DisableMPLo"

the reason why this eventually works is because msbuild seems to simply ignore clp parameters that do not match any predefined value and take the first build file it finds if the btdfproj file path is omitted completely

tfabraham commented 6 years ago

[tfabraham@11/14/2014] I thought it was your modified XSLT that pushed the path over the "limit". You're saying that even the default XSLT can cause an issue. According to this shortcuts are not limited, the Properties dialog box is limited. I don't know if the way WiX creates shortcuts internally is limited.