0

I am attempting to make modifications to a ClickOnce deployment manifest. One thing I need to do is setup the manifest to deploy an icon to the desktop. To do this you need to add the createDesktopShortcut attribute with a true value to the Deployment node.

For Example, this is a snippet of a working deployment file (there are some minor modifications).

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd"
                manifestVersion="1.0" 
                xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" 
                xmlns="urn:schemas-microsoft-com:asm.v2" 
                xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"
                xmlns:xrml="urn:mpeg:mpeg21:2003:01-REL-R-NS" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"
                xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" 
                xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" 
                xmlns:co.v2="urn:schemas-microsoft-com:clickonce.v2">
  <assemblyIdentity name="My.app" version="1.2.3.4" publicKeyToken="redacted" language="neutral" processorArchitecture="x86" xmlns="urn:schemas-microsoft-com:asm.v1" />
  <deployment trustURLParameters="true" install="true" 
              minimumRequiredVersion="1.2.3.4"
              co.v1:createDesktopShortcut="true">
    <subscription>
      <update>
        <beforeApplicationStartup />
      </update>
    </subscription>
    <deploymentProvider codebase="redacted" />
  </deployment>
</asmv1:assembly>

Note that the attribute "createDesktopShortcut" is prefixed with the namespace co.v1 This prefix appears to be required, however if you attempt to use Power Shell to create this element it will add it without the prefix, making the xml invalid.

[xml]$DeploymentManifest = Get-Content -Path $DeploymentPath 
$DeploymentManifest.assembly.SetAttribute("xmlns:co.v1", "urn:schemas-microsoft-com:clickonce.v1")
$DeploymentManifest.assembly.deployment.SetAttribute('co.v1:createDesktopShortcut',
                                                         'true')

This results in the following Deployment tag:

    <deployment trustURLParameters="true" install="true" 
            minimumRequiredVersion="1.2.3.4" 
            createDesktopShortcut="true" >

This would be fine, however ClickOnce can't seem to process that attribute without the prefix. Any guidance in any direction as to why this happens or how I can cleanly work around it is appreciated.

1
  • I just want to recommend against manual modification of ClickOnce deployment manifests. It creates a lot of problems. After a lot of work I fell back to a much more standard approach and its running much clearner. To be clear, this was part of a process of migrating a certificate to SHA256 for a product targeting .NET 4.0 machines which creates a number of issues. Commented Jun 16, 2015 at 14:28

1 Answer 1

1

I'm not quite sure why that doesn't work. It seems to contradict the documentation for the SetAttribute method. However using the other overload of SetAttribute or SetAttributeNode did work for me.

via SetAttribute:

$DeploymentManifest.assembly.deployment.SetAttribute('createDesktopShortcut', 'urn:schemas-microsoft-com:clickonce.v1', 'true')

or via SetAttributeNode:

$att = $DeploymentManifest.assembly.deployment.SetAttributeNode('createDesktopShortcut', 'urn:schemas-microsoft-com:clickonce.v1')
$att.Value = 'true'

and the output:

<deployment trustURLParameters="true" 
    install="true" 
    minimumRequiredVersion="1.2.3.4" 
    co.v1:createDesktopShortcut="true">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.