How can I allow a ClickOnce application to use Url parameters when building with mage.exe?

StackOverflow https://stackoverflow.com/questions/19572959

  •  01-07-2022
  •  | 
  •  

Question

I am building an online only ClickOnce application using mage.exe that needs to get parameters when launched. I would like use URL parameters for this, but I can't find a way to do this in mage.exe. VS and mageui have the trust URL parameters option, but nothing in mage. Is there something I am missing?

If not, where do I need to set this value? I tried setting it in the .application file, but that doesn't work. That is, the app launches fine, but the activation url is still empty. I assume that I need to change other xml files, but I don't know which ones.

<deployment install="false" mapFileExtensions="true" trustURLParameters="true" />

Thanks, Erick

Was it helpful?

Solution

It turns out that mage.exe does not have the ability add the trust URL parameters attribute. VS and MageUI.exe can both do it, but if you need to use mage.exe (i.e., build script) then you need to directly modify the XML files. I found a thread on MSDN that contained the following PowerShell approach which works well.

[System.Xml.XmlDocument] $manifest = new-object System.Xml.XmlDocument
$manifest.load( (resolve-path $deploymentManifest) )
[System.Xml.XmlNode] $updateNode = $manifest.assembly.deployment.subscription.update
$updateNode.RemoveAll()
$updateNode.AppendChild($manifest.CreateElement("beforeApplicationStartup", "urn:schemas-microsoft-com:asm.v2"))
$trustUrlParameters = $manifest.CreateAttribute("trustURLParameters")
$trustUrlParameters.set_Value("true")
$manifest.assembly.deployment.SetAttributeNode($trustUrlParameters)
SaveXML "$deploymentManifest" $manifest
#Sign the mangled deployment manifest
mage -sign "$deploymentManifest" -CertHash $signingCertificateThumbPrint
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top