Can I get the published ClickOnce product name from within the application?

I have a ClickOnce publication name different from the assembly name. For discussion, this is "Appendix 6.0." I set it in the properties for my project. Is there any way to get this value inside the program?

+3
source share
3 answers

The answer can be found in ClickOnce Run at startup . Essentially, you use InPlaceHostingManager to get the ClickOnce manifest and read it. It seems to me that this is an asynchronous method, but this is the only thing that still works. Simplifications are welcome. See DeploymentDescription Description Web Page.

var inPlaceHostingManager = new InPlaceHostingManager(ApplicationDeployment.CurrentDeployment.UpdateLocation, false);
inPlaceHostingManager.GetManifestCompleted += ((sender, e) =>
{
    try
    {
        var deploymentDescription = new DeploymentDescription(e.DeploymentManifest);
        string productName = deploymentDescription.Product;
        ***DoSomethingToYour(productName);***

        // - use this later -
        //var commandBuilder = new StartMenuCommandBuilder(deploymentDescription);
        //string startMenuCommand = commandBuilder.Command;
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace);
    }
});
+2
source

Add a link to Microsoft.Build.Tasks.v4.0.dll, then run this:

if (null != AppDomain.CurrentDomain.ActivationContext)
{
    DeployManifest manifest;
    using (MemoryStream stream = new MemoryStream(AppDomain.CurrentDomain.ActivationContext.DeploymentManifestBytes))
    {
        manifest = (DeployManifest)ManifestReader.ReadManifest("Deployment", stream, true);
    }
    // manifest.Product has the name you want
}
else
{
   // not deployed
}

DeployManifest , Publisher SupportUrl.

+3

ApplicationDeployment.UpdatedApplicationFullName Property

+2
source

All Articles