From 9f0797388a5e2050f3c9f44f17bb5ed2c7a18f61 Mon Sep 17 00:00:00 2001 From: jreed519 Date: Mon, 15 Jun 2015 14:31:51 -0500 Subject: [PATCH 1/4] Added CreateDesktopShortcut and Timestamping for ClickOnce --- .../ClickOnce/ClickOnceDeployment.cs | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/Source/Activities/ClickOnce/ClickOnceDeployment.cs b/Source/Activities/ClickOnce/ClickOnceDeployment.cs index a3f2bb4..8b31a9d 100644 --- a/Source/Activities/ClickOnce/ClickOnceDeployment.cs +++ b/Source/Activities/ClickOnce/ClickOnceDeployment.cs @@ -21,6 +21,16 @@ public sealed class ClickOnceDeployment : BaseCodeActivity { private InArgument processor = "x86"; + /// + /// Create a desktop shortcut for the Application + /// + public InArgument CreateDesktopShortcut { get; set; } + + /// + /// Timestamp Server Location + /// + public InArgument TimestampUri { get; set; } + /// /// Sets the Processor to use. Default is x86. /// @@ -103,6 +113,8 @@ protected override void InternalExecute() string installLocation = this.InstallLocation.Get(this.ActivityContext); string targetFrameworkVersion = this.TargetFrameworkVersion.Get(this.ActivityContext); string manifestCertificateThumbprint = this.ManifestCertificateThumbprint.Get(this.ActivityContext); + string timestampUri = this.TimestampUri.Get(this.ActivityContext); + bool createDesktopShortcut = this.CreateDesktopShortcut.Get(this.ActivityContext); try { @@ -122,26 +134,28 @@ protected override void InternalExecute() string manifestCertificateThumbprintArg = !string.IsNullOrEmpty(manifestCertificateThumbprint) ? "-CertHash " + manifestCertificateThumbprint : string.Empty; string certFilePathArg = !string.IsNullOrEmpty(certFilePath) ? "-CertFile " + certFilePath : string.Empty; string certPasswordArg = !string.IsNullOrEmpty(certPassword) ? "-Password " + certPassword : string.Empty; + string timestampUriArg = !string.IsNullOrEmpty(timestampUri) ? "-TimestampUri " + timestampUri : string.Empty; // Create Application Manifest string args = "-New Application -Processor " + this.Processor.Get(this.ActivityContext) + " -ToFile \"" + toFile + "\\" + applicationName + ".exe.manifest\" -name " + applicationName + " -Version " + version + " -FromDirectory \"" + toFile + "\""; RunMage(mageFilePath, args); // Sign Application Manifest - args = "-Sign \"" + toFile + "\\" + applicationName + ".exe.manifest\" " + manifestCertificateThumbprintArg + " " + certFilePathArg + " " + certPasswordArg; - RunMage(mageFilePath, args); + //args = "-Sign \"" + toFile + "\\" + applicationName + ".exe.manifest\" " + manifestCertificateThumbprintArg + " " + certFilePathArg + " " + certPasswordArg; + //RunMage(mageFilePath, args); // rename all files to have a .deploy RenameFiles(toFile); // Sign Application Manifest - args = "-Sign \"" + toFile + "\\" + applicationName + ".exe.manifest\" " + manifestCertificateThumbprintArg + " " + certFilePathArg + " " + certPasswordArg; + args = "-Sign \"" + toFile + "\\" + applicationName + ".exe.manifest\" " + manifestCertificateThumbprintArg + " " + certFilePathArg + " " + certPasswordArg + " " + timestampUriArg; + RunMage(mageFilePath, args); - CreateDeploymentManifest(version, applicationName, publishLocation, targetFrameworkVersion); + CreateDeploymentManifest(version, applicationName, publishLocation, targetFrameworkVersion, createDesktopShortcut); // Sign Deployment Manifest - args = "-Sign \"" + publishLocation + "\\" + applicationName + ".application\" " + manifestCertificateThumbprintArg + " " + certFilePathArg + " " + certPasswordArg; + args = "-Sign \"" + publishLocation + "\\" + applicationName + ".application\" " + manifestCertificateThumbprintArg + " " + certFilePathArg + " " + certPasswordArg + " " + timestampUriArg; RunMage(mageFilePath, args); // Copy Deploy Manifest to parent folder @@ -213,7 +227,7 @@ private static void RunMage(string mageFilePath, string args) } } - private static void CreateDeploymentManifest(string version, string applicationName, string publishLocation, string targetFrameworkVersion) + private static void CreateDeploymentManifest(string version, string applicationName, string publishLocation, string targetFrameworkVersion, bool createDesktopShortcut) { Dictionary metadata = new Dictionary(); metadata.Add("TargetPath", "Application Files\\" + applicationName + "_" + version + "\\" + applicationName + ".exe.manifest"); @@ -231,7 +245,7 @@ private static void CreateDeploymentManifest(string version, string applicationN OutputManifest = new TaskItem(publishLocation + "\\" + applicationName + ".application"), MapFileExtensions = true, EntryPoint = new TaskItem(publishLocation + @"\Application Files\" + applicationName + "_" + version + "\\" + applicationName + ".exe.manifest", metadata), - CreateDesktopShortcut = false, + CreateDesktopShortcut = createDesktopShortcut, TargetFrameworkVersion = targetFrameworkVersion, TargetFrameworkMoniker = ".NETFramework,Version=v" + targetFrameworkVersion, MinimumRequiredVersion = version From 05603b47794f0181a8ef44f9a6d296ce979fe22c Mon Sep 17 00:00:00 2001 From: jreed519 Date: Mon, 15 Jun 2015 15:01:47 -0500 Subject: [PATCH 2/4] Adding Publisher Information --- Source/Activities/ClickOnce/ClickOnceDeployment.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Source/Activities/ClickOnce/ClickOnceDeployment.cs b/Source/Activities/ClickOnce/ClickOnceDeployment.cs index 8b31a9d..b39db07 100644 --- a/Source/Activities/ClickOnce/ClickOnceDeployment.cs +++ b/Source/Activities/ClickOnce/ClickOnceDeployment.cs @@ -21,6 +21,11 @@ public sealed class ClickOnceDeployment : BaseCodeActivity { private InArgument processor = "x86"; + /// + /// Publisher + /// + public InArgument Publisher { get; set; } + /// /// Create a desktop shortcut for the Application /// @@ -115,6 +120,7 @@ protected override void InternalExecute() string manifestCertificateThumbprint = this.ManifestCertificateThumbprint.Get(this.ActivityContext); string timestampUri = this.TimestampUri.Get(this.ActivityContext); bool createDesktopShortcut = this.CreateDesktopShortcut.Get(this.ActivityContext); + string publisher = this.Publisher.Get(this.ActivityContext); try { @@ -135,9 +141,10 @@ protected override void InternalExecute() string certFilePathArg = !string.IsNullOrEmpty(certFilePath) ? "-CertFile " + certFilePath : string.Empty; string certPasswordArg = !string.IsNullOrEmpty(certPassword) ? "-Password " + certPassword : string.Empty; string timestampUriArg = !string.IsNullOrEmpty(timestampUri) ? "-TimestampUri " + timestampUri : string.Empty; + string publisherArg = !string.IsNullOrEmpty(publisher) ? "-Publisher " + publisher : string.Empty; // Create Application Manifest - string args = "-New Application -Processor " + this.Processor.Get(this.ActivityContext) + " -ToFile \"" + toFile + "\\" + applicationName + ".exe.manifest\" -name " + applicationName + " -Version " + version + " -FromDirectory \"" + toFile + "\""; + string args = "-New Application -Processor " + this.Processor.Get(this.ActivityContext) + " -ToFile \"" + toFile + "\\" + applicationName + ".exe.manifest\" -name " + applicationName + " -Version " + version + " -FromDirectory \"" + toFile + "\"" + " -publisher " + publisher; RunMage(mageFilePath, args); // Sign Application Manifest @@ -152,7 +159,7 @@ protected override void InternalExecute() RunMage(mageFilePath, args); - CreateDeploymentManifest(version, applicationName, publishLocation, targetFrameworkVersion, createDesktopShortcut); + CreateDeploymentManifest(version, applicationName, publishLocation, targetFrameworkVersion, createDesktopShortcut, publisher); // Sign Deployment Manifest args = "-Sign \"" + publishLocation + "\\" + applicationName + ".application\" " + manifestCertificateThumbprintArg + " " + certFilePathArg + " " + certPasswordArg + " " + timestampUriArg; @@ -227,7 +234,7 @@ private static void RunMage(string mageFilePath, string args) } } - private static void CreateDeploymentManifest(string version, string applicationName, string publishLocation, string targetFrameworkVersion, bool createDesktopShortcut) + private static void CreateDeploymentManifest(string version, string applicationName, string publishLocation, string targetFrameworkVersion, bool createDesktopShortcut, string publisher) { Dictionary metadata = new Dictionary(); metadata.Add("TargetPath", "Application Files\\" + applicationName + "_" + version + "\\" + applicationName + ".exe.manifest"); @@ -237,6 +244,7 @@ private static void CreateDeploymentManifest(string version, string applicationN AssemblyName = applicationName + ".application", AssemblyVersion = version, Product = applicationName, + Publisher = publisher, // DeploymentUrl = installLocation, Install = true, From ce0f5c9af339ea4295e542617e49aeef8c66e0f4 Mon Sep 17 00:00:00 2001 From: jreed519 Date: Fri, 19 Jun 2015 14:46:52 -0500 Subject: [PATCH 3/4] Added icon option to ClickOnce Activity. --- Source/Activities/ClickOnce/ClickOnceDeployment.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/Activities/ClickOnce/ClickOnceDeployment.cs b/Source/Activities/ClickOnce/ClickOnceDeployment.cs index b39db07..42ba184 100644 --- a/Source/Activities/ClickOnce/ClickOnceDeployment.cs +++ b/Source/Activities/ClickOnce/ClickOnceDeployment.cs @@ -30,7 +30,12 @@ public sealed class ClickOnceDeployment : BaseCodeActivity /// Create a desktop shortcut for the Application /// public InArgument CreateDesktopShortcut { get; set; } - + + /// + /// Name of Icon File + /// + public InArgument IconFile { get; set; } + /// /// Timestamp Server Location /// @@ -121,6 +126,7 @@ protected override void InternalExecute() string timestampUri = this.TimestampUri.Get(this.ActivityContext); bool createDesktopShortcut = this.CreateDesktopShortcut.Get(this.ActivityContext); string publisher = this.Publisher.Get(this.ActivityContext); + string iconFile = this.IconFile.Get(this.ActivityContext); try { @@ -141,10 +147,10 @@ protected override void InternalExecute() string certFilePathArg = !string.IsNullOrEmpty(certFilePath) ? "-CertFile " + certFilePath : string.Empty; string certPasswordArg = !string.IsNullOrEmpty(certPassword) ? "-Password " + certPassword : string.Empty; string timestampUriArg = !string.IsNullOrEmpty(timestampUri) ? "-TimestampUri " + timestampUri : string.Empty; - string publisherArg = !string.IsNullOrEmpty(publisher) ? "-Publisher " + publisher : string.Empty; + string iconFileArg = !string.IsNullOrEmpty(iconFile) ? " -IconFile " + iconFile : string.Empty; // Create Application Manifest - string args = "-New Application -Processor " + this.Processor.Get(this.ActivityContext) + " -ToFile \"" + toFile + "\\" + applicationName + ".exe.manifest\" -name " + applicationName + " -Version " + version + " -FromDirectory \"" + toFile + "\"" + " -publisher " + publisher; + string args = "-New Application -Processor " + this.Processor.Get(this.ActivityContext) + " -ToFile \"" + toFile + "\\" + applicationName + ".exe.manifest\" -name " + applicationName + " -Version " + version + " -FromDirectory \"" + toFile + "\"" + iconFileArg; RunMage(mageFilePath, args); // Sign Application Manifest From 130d241a9e7e0f3d5acaeb8338e2c399be8fde7f Mon Sep 17 00:00:00 2001 From: jreed519 Date: Fri, 26 Jun 2015 13:52:55 -0500 Subject: [PATCH 4/4] Added functionality to allow for DeploymentURL to be a part of deployment manifest. --- .../ClickOnce/ClickOnceDeployment.cs | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Source/Activities/ClickOnce/ClickOnceDeployment.cs b/Source/Activities/ClickOnce/ClickOnceDeployment.cs index 42ba184..ba775ec 100644 --- a/Source/Activities/ClickOnce/ClickOnceDeployment.cs +++ b/Source/Activities/ClickOnce/ClickOnceDeployment.cs @@ -1,18 +1,19 @@ //----------------------------------------------------------------------- // (c) http://TfsBuildExtensions.codeplex.com/. This source is subject to the Microsoft Permissive License. See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx. All other rights reserved. //----------------------------------------------------------------------- + +using System; +using System.Activities; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using Microsoft.Build.Tasks; +using Microsoft.Build.Utilities; +using Microsoft.TeamFoundation.Build.Client; + namespace TfsBuildExtensions.Activities.ClickOnce { - using System; - using System.Activities; - using System.Collections.Generic; - using System.Diagnostics; - using System.Globalization; - using System.IO; - using Microsoft.Build.Tasks; - using Microsoft.Build.Utilities; - using Microsoft.TeamFoundation.Build.Client; - /// /// ClickOnceDeployment /// @@ -165,7 +166,7 @@ protected override void InternalExecute() RunMage(mageFilePath, args); - CreateDeploymentManifest(version, applicationName, publishLocation, targetFrameworkVersion, createDesktopShortcut, publisher); + CreateDeploymentManifest(version, applicationName, publishLocation, installLocation, targetFrameworkVersion, createDesktopShortcut, publisher); // Sign Deployment Manifest args = "-Sign \"" + publishLocation + "\\" + applicationName + ".application\" " + manifestCertificateThumbprintArg + " " + certFilePathArg + " " + certPasswordArg + " " + timestampUriArg; @@ -240,7 +241,7 @@ private static void RunMage(string mageFilePath, string args) } } - private static void CreateDeploymentManifest(string version, string applicationName, string publishLocation, string targetFrameworkVersion, bool createDesktopShortcut, string publisher) + private static void CreateDeploymentManifest(string version, string applicationName, string publishLocation, string installLocation, string targetFrameworkVersion, bool createDesktopShortcut, string publisher) { Dictionary metadata = new Dictionary(); metadata.Add("TargetPath", "Application Files\\" + applicationName + "_" + version + "\\" + applicationName + ".exe.manifest"); @@ -252,7 +253,7 @@ private static void CreateDeploymentManifest(string version, string applicationN Product = applicationName, Publisher = publisher, - // DeploymentUrl = installLocation, + DeploymentUrl = installLocation + applicationName + ".application", Install = true, UpdateEnabled = true, UpdateMode = "Foreground",