Project ClickOnce Advanced Deployment Webpage
From Frederick Chapleau Wiki
Great, but ... why?
When a user look a the boring VS 2008/2005 Click Once statup page, they see a version. But this is not the actual released version but the publication version.
Also, the page is not customizable in anyway, and it is overwriten after every publication.
So, that is why I created this little ASP.Net page, that is dynamicaly dertermining the version of the publication, the version of the application (entry assembly), and validating .NET pre-requisites based on the user agent.
Installation
Simple: copy the code below in a file named default.aspx (or the name of default asp.net document of the website/vdirectory).
The page will automatically resolve the application of resume help.
The code
<%@ Page Language="C#" %> <%@ Import Namespace="System.IO" %> <%@ Import Namespace="System.Xml" %> <%@ Import Namespace="System.Diagnostics" %> <% // Get the current applications string[] applications = Directory.GetFiles(Server.MapPath("./"), "*.application"); if(applications.Length==0) { Response.Write("No application could be located."); Response.End(); } string currentApplicationPath = applications[0]; // Load the Application File XmlDocument doc = new XmlDocument(); doc.Load(currentApplicationPath); // Get the NamespaceManager XmlNamespaceManager mgr = new XmlNamespaceManager(doc.NameTable); mgr.AddNamespace("asmv2", "urn:schemas-microsoft-com:asm.v2"); mgr.AddNamespace("asmv1", "urn:schemas-microsoft-com:asm.v1"); // Get the Publication Version string publicationProduct = ((XmlElement)doc.SelectSingleNode("/asmv1:assembly/asmv1:description", mgr)).GetAttribute("asmv2:product"); string publicationPublisher = ((XmlElement)doc.SelectSingleNode("/asmv1:assembly/asmv1:description", mgr)).GetAttribute("asmv2:publisher"); string publicationVersion = ((XmlElement)doc.SelectSingleNode("/asmv1:assembly/asmv1:assemblyIdentity", mgr)).GetAttribute("version"); string applicationCodeBase = ((XmlElement)doc.SelectSingleNode("/asmv1:assembly/asmv2:dependency/asmv2:dependentAssembly", mgr)).GetAttribute("codebase"); // Get the most recent manifest XmlDocument manifest = new XmlDocument(); manifest.Load(Server.MapPath(applicationCodeBase)); XmlNamespaceManager mgrCodeBase = new XmlNamespaceManager(manifest.NameTable); mgr.AddNamespace("asmv2", "urn:schemas-microsoft-com:asm.v2"); mgr.AddNamespace("asmv1", "urn:schemas-microsoft-com:asm.v1"); // Get deployed application string startupApplication = ((XmlElement)manifest.SelectSingleNode("/asmv1:assembly/asmv2:entryPoint/asmv2:commandLine", mgr)).GetAttribute("file") + ".deploy"; string currentApplicationSpec = Path.GetDirectoryName(currentApplicationPath) + "\\" + Path.GetDirectoryName(applicationCodeBase) + "\\" + startupApplication; // Get the File Version FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(currentApplicationSpec); FileInfo fi = new FileInfo(currentApplicationSpec); %> <html> <head> <title><%=publicationProduct%> - <%=publicationPublisher %></title> </head> <body> <h1><%=publicationProduct%></h1> <h2><%=publicationPublisher %></h2> <h3>Current Version</h3> <table> <tr> <td>Application Version: </td> <td><b><%=fvi.FileVersion%></b></td> </tr> <tr> <td>Deployment Version: </td> <td><b><%=publicationVersion %></b></td> </tr> <tr> <td>Published on:</td> <td><b><%=fi.LastWriteTime %></b></td> </tr> </table> <br /> <h3>Validating Pre-Requisites</h3> .NET Framework Version 2.0 : <b><%=Request.UserAgent.Contains(".NET CLR 2.0") %></b> [<a href="http://www.microsoft.com/downloads/details.aspx?familyid=0856eacb-4362-4b0d-8edd-aab15c5e04f5&displaylang=en">Install</a>]<br /> .NET Framework Version 3.0 : <b><%=Request.UserAgent.Contains(".NET CLR 3.0")%></b> [<a href="http://www.microsoft.com/downloads/details.aspx?familyid=10cc340b-f857-4a14-83f5-25634c3bf043&displaylang=en">Install</a>]<br /> <br /> <a href="<%=Path.GetFileName(applications[0]) %>">Launch</a> | <a href="setup.exe">Download</a> </body> </html>

