Skip to content

Conversation

jackmtpt
Copy link
Contributor

This PR changes the ClickOnce signer to better detect which .dll.manifest or .exe.manifest Application manifest file to sign. It reads the supplied .vsto/.application Deployment manifest file and parses out the name of the Application manifest that's referenced, and then passes that to mage for updating.

// we only try and parse absolute uris, because a relative uri can just be treated like a file path for our purposes
if (Uri.TryCreate(applicationManifestFileNameAttribute.Value, UriKind.Absolute, out var uri))
{
Path.GetFileName(uri.LocalPath); // works for http(s) and file:// uris
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a bug here. I think you meant:

Suggested change
Path.GetFileName(uri.LocalPath); // works for http(s) and file:// uris
return Path.GetFileName(uri.LocalPath); // works for http(s) and file:// uris

Seems worth adding a unit test for this case. I think you can convert your new, existing unit test into a theory and parameterize codebase with both scenarios.


FileInfo? manifestFile = filteredFiles.SingleOrDefault(f => ".manifest".Equals(f.Extension, StringComparison.OrdinalIgnoreCase));
var appManifestFromDeploymentManifest = GetApplicationManifestForDeploymentManifest(file);
FileInfo? manifestFile = filteredFiles.SingleOrDefault(f => f.Name.Equals(appManifestFromDeploymentManifest, StringComparison.OrdinalIgnoreCase));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is avoidable if appManifestFromDeploymentManifest is null.

Also, can we rename manifestFile to applicationManifestFile since now we're dealing with potentially many different kinds of manifest files. We had deployment and application manifests, but now we're dealing with other manifests (like assembly manifests).

}

/// <summary>
/// Try and find the application manifest (.manifest) file from a clickonce application manifest (.application / .vsto
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be:

Suggested change
/// Try and find the application manifest (.manifest) file from a clickonce application manifest (.application / .vsto
/// Try and find the application manifest (.manifest) file from a clickonce deployment manifest (.application / .vsto

var xml = new XmlDocument();
xml.Load(deploymentManifest.FullName);
// there should only be a single result here, if the file is a valid clickonce manifest.
var dependentAssemblies = xml.GetElementsByTagName("dependentAssembly");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prefer using the explicit type if the implied type is not super obvious. It will facilitate understanding both in a browser and IDE.

@dtivel
Copy link
Collaborator

dtivel commented Sep 18, 2024

@jackmtpt, thank you for your contribution! We appreciate it.

Can you open an issue with repro steps and link it? It would help us better understand the scenario you're trying to improve.

I left some feedback. I also created a branch with my suggested changes. You can cherry pick the latest commit if you want.

@dtivel
Copy link
Collaborator

dtivel commented Oct 11, 2024

There's been no activity here for weeks, so I'm closing this in favor of #773.

@dtivel dtivel closed this Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants