Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to set product name without changing assembly name #131

Open
IGx89 opened this issue Aug 13, 2021 · 3 comments
Open

Ability to set product name without changing assembly name #131

IGx89 opened this issue Aug 13, 2021 · 3 comments
Assignees

Comments

@IGx89
Copy link

IGx89 commented Aug 13, 2021

Hello! I was trying to use dotnet-mage to update the product name (assembly.description.name) of my application in the deployment manifest, but ran into a blocker: updating the product name also changes assemblyIdentity.name to the product name. They need to be different (product name is what's on the Start Menu, etc., while assembly name is a non-user-friendly assembly name), but dotnet-mage appears to have no way to set them separately.

The description of the -Name option says "The name that is used to identify the application. ClickOnce will use this name to identify the application in the Start menu (if the application is configured to install itself) and in Permission Elevation dialog boxes." That seems to imply it should update product name but not assembly name. My understanding of ClickOnce manifests is admittedly lacking so there could be a very good reason they're linked in your tool, though unfortunately in my situation they can't be the same (users would get an error upon startup due to the assembly identity name having changed).

In the meantime I'm simply using sed to update the manifest and then dotnet-mage to sign it, but it would be convenient to be able to do it all through the tool.

@NikolaMilosavljevic
Copy link
Member

[Triage] @IGx89 are you aware if this issue reproes with old .NET FX tool Mage, or is it unique to dotnet-mage?

@NikolaMilosavljevic please investigate.

@IGx89
Copy link
Author

IGx89 commented Aug 30, 2021

Thanks for investigating! Just checked, it reproes with the old .NET FX tool as well.

@alansingfield
Copy link

You can fix this by editing the XML between generating the Deployment Manifest (.application file) and signing it.
Look at the bottom section of the script where I'm doing the XML manipulation.
There are all sorts of warts in MAGE and this kind of works around them.

# Create the application manifest
dotnet mage `
    -New Application `
    -ToFile         $appManifest `
    -Name           $applicationTitle `
    -Version        $version `
    -FromDirectory  $appFolder `
    -IconFile       $iconFile

# Sign the application manifest
dotnet mage `
    -Sign           $appManifest `
    -CertFile       $signingCert

# Create the deployment manifest (exename.application) file
dotnet mage `
    -New Deployment `
    -Install        true `
    -Name           $clickOnceApplicationIdentity `
    -Publisher      $company `
    -Version        $version `
    -AppManifest    $appManifest `
    -ToFile         $deploymentManifest `
    -ProviderURL    $upgradeUrl `
    -Processor      $processor 

# For some reason the MinVersion parameter only works on Update so update the .application file here
dotnet mage `
    -Update         $deploymentManifest `
    -MinVersion     $version `
    -Publisher      $company

    
# Certain properties are not generated by dotnet mage (or the older Mage.exe)
# but were generated by the old <GenerateDeploymentManifest> build task. Luckily
# they are just plain XML so we can add them in easily enough.

[xml]$xml = Get-Content $deploymentManifest

# Set up the namespaces
[System.Xml.XmlNamespaceManager] $nsm = New-Object System.Xml.XmlNamespaceManager $xml.NameTable

$asmv1 = 'urn:schemas-microsoft-com:asm.v1'
$asmv2 = 'urn:schemas-microsoft-com:asm.v2'
$cov1 = 'urn:schemas-microsoft-com:clickonce.v1'

$nsm.AddNamespace('asmv1', $asmv1) 
$nsm.AddNamespace('asmv2', $asmv2)

$assemblyIdentity = $xml.SelectSingleNode('asmv1:assembly/asmv1:assemblyIdentity', $nsm)
$asmv1Description = $xml.SelectSingleNode('asmv1:assembly/asmv1:description', $nsm)
$asmv1Deployment =  $xml.SelectSingleNode('asmv1:assembly/asmv2:deployment', $nsm)

# Update the XML attributes
$assemblyIdentity.SetAttribute('name', $clickOnceApplicationIdentity)

$asmv1Description.SetAttribute('publisher', $asmv2, $company)
$asmv1Description.SetAttribute('product',   $asmv2, $applicationTitle)

# This tells ClickOnce that the files will all have the .deploy extension
$asmv1Deployment.SetAttribute('mapFileExtensions', 'true')

# Turns on the desktop shortcuts.
$asmv1Deployment.SetAttribute('createDesktopShortcut', $cov1, 'true')

# When saving, needs the absolute path
$xml.Save((Resolve-Path $deploymentManifest));

# Sign the deployment manifest
    
dotnet mage `
    -Sign           $deploymentManifest `
    -CertFile       $signingCert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants