Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions Documentation/dotnet-mage/ApplicationDeployment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
using System;

namespace ClickOnceHelper
{
public class ApplicationDeployment
{
private static ApplicationDeployment currentDeployment = null;
private static bool currentDeploymentInitialized = false;

private static bool isNetworkDeployed = false;
private static bool isNetworkDeployedInitialized = false;

public static bool IsNetworkDeployed
{
get
{
if (!isNetworkDeployedInitialized)
{
bool.TryParse(Environment.GetEnvironmentVariable("ClickOnce_IsNetworkDeployed"), out ApplicationDeployment.isNetworkDeployed);
ApplicationDeployment.isNetworkDeployedInitialized = true;
}

return ApplicationDeployment.isNetworkDeployed;
}
}

public static ApplicationDeployment CurrentDeployment
{
get
{
if (!currentDeploymentInitialized)
{
ApplicationDeployment.currentDeployment = IsNetworkDeployed ? new ApplicationDeployment() : null;
ApplicationDeployment.currentDeploymentInitialized = true;
}

return ApplicationDeployment.currentDeployment;
}
}

public Uri ActivationUri
{
get
{
Uri.TryCreate(Environment.GetEnvironmentVariable("ClickOnce_ActivationUri"), UriKind.Absolute, out Uri val);
return val;
}
}

public Version CurrentVersion
{
get
{
Version.TryParse(Environment.GetEnvironmentVariable("ClickOnce_CurrentVersion"), out Version val);
return val;
}
}
public string DataDirectory
{
get { return Environment.GetEnvironmentVariable("ClickOnce_DataDirectory"); }
}

public bool IsFirstRun
{
get
{
bool.TryParse(Environment.GetEnvironmentVariable("ClickOnce_IsFirstRun"), out bool val);
return val;
}
}

public DateTime TimeOfLastUpdateCheck
{
get
{
DateTime.TryParse(Environment.GetEnvironmentVariable("ClickOnce_TimeOfLastUpdateCheck"), out DateTime value);
return value;
}
}
public string UpdatedApplicationFullName
{
get
{
return Environment.GetEnvironmentVariable("ClickOnce_UpdatedApplicationFullName");
}
}

public Version UpdatedVersion
{
get
{
Version.TryParse(Environment.GetEnvironmentVariable("ClickOnce_UpdatedVersion"), out Version val);
return val;
}
}

public Uri UpdateLocation
{
get
{
Uri.TryCreate(Environment.GetEnvironmentVariable("ClickOnce_UpdateLocation"), UriKind.Absolute, out Uri val);
return val;
}
}

public Version LauncherVersion
{
get
{

Version.TryParse(Environment.GetEnvironmentVariable("ClickOnce_LauncherVersion"), out Version val);
return val;
}
}

private ApplicationDeployment()
{
// As an alternative solution, we could initialize all properties here
}
}
}
5 changes: 5 additions & 0 deletions src/clickonce/MageCLI/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,11 @@ internal enum ErrorMessages
/// </summary>
InvalidUseManifestForTrust,

/// <summary>
/// The -TrustURLParameters option must be "true", "false", "t", or "f" - "{0}"
/// </summary>
InvalidTrustURLParameters,

/// <summary>
/// The IncludeProviderURL option is set to true, but no deployment provider Url is provided.
/// </summary>
Expand Down
9 changes: 8 additions & 1 deletion src/clickonce/MageCLI/Application.resx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ Options
-TimeStampUri &lt;uri&gt; -ti
-ToFile &lt;file_name&gt; -t
-TrustLevel &lt;level&gt; -tr
-TrustURLParameters &lt;true|false&gt; -tu
-UseManifestForTrust &lt;true|false&gt; -um
-Version &lt;version&gt; -v

Expand Down Expand Up @@ -344,6 +345,9 @@ Options:
Example:
-TrustLevel FullTrust

-TrustURLParameters &lt;true|false&gt; -tu
Specifies if URL parameters will be trusted and passed to the application.

-UseManifestForTrust &lt;true|false&gt; -um
Specifies if the application manifest will be used for certification and
branding information.
Expand Down Expand Up @@ -437,6 +441,9 @@ Options:
<data name="InvalidUrl" xml:space="preserve">
<value>The URL is not of the proper format - "{0}"</value>
</data>
<data name="InvalidTrustURLParameters" xml:space="preserve">
<value>The -TrustURLParameters option must be "true", "false", "t", or "f" - "{0}"</value>
</data>
<data name="InvalidUseManifestForTrust" xml:space="preserve">
<value>The -UseManifestForTrust option must be "true", "false", "t", or "f" - "{0}"</value>
</data>
Expand Down Expand Up @@ -567,4 +574,4 @@ Options:
<data name="InvalidSigningPlatform" xml:space="preserve">
<value>Signing is only supported on Windows.</value>
</data>
</root>
</root>
38 changes: 35 additions & 3 deletions src/clickonce/MageCLI/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ public enum DigestAlgorithmValue
[CommandLineArgument(LongName = "CryptoProvider", ShortName = "csp")]
public string cryptoProviderName = null;

[CommandLineArgument(LongName = "TrustURLParameters", ShortName = "tu")]
public string trustUrlParametersString = null;

[CommandLineArgument(LongName = "UseManifestForTrust", ShortName = "um")]
public string useApplicationManifestForTrustInfoString = null;

Expand Down Expand Up @@ -208,6 +211,11 @@ public enum DigestAlgorithmValue
/// </summary>
private TriStateBool useApplicationManifestForTrustInfo = TriStateBool.Undefined;

/// <summary>
/// TrustURLParameters, in boolean form, parsed from the trustUrlParametersString member
/// </summary>
private TriStateBool trustUrlParameters = TriStateBool.Undefined;

/// <summary>
/// This object is cached between CanExecute(), where it is opened and
/// tested for validity, and Execute(), where it actually gets used.
Expand Down Expand Up @@ -793,6 +801,28 @@ private bool CanExecuteInner()
}
}

// Validate the TrustUrlParameters option, if given
if (trustUrlParametersString != null)
{
switch (trustUrlParametersString.ToLower(CultureInfo.InvariantCulture))
{
case "true":
case "t":
trustUrlParameters = TriStateBool.True;
break;

case "false":
case "f":
trustUrlParameters = TriStateBool.False;
break;

default:
result = false;
Application.PrintErrorMessage(ErrorMessages.InvalidTrustURLParameters, trustUrlParametersString);
break;
}
}

if ((Requested(Operations.GenerateApplicationManifest) || Requested(Operations.UpdateApplicationManifest)) &&
useApplicationManifestForTrustInfo != TriStateBool.True)
{
Expand Down Expand Up @@ -860,7 +890,8 @@ private bool CheckForInvalidParameters()
errors += CheckForFileTypeSpecificOption("Deployment", "AppProviderUrl", applicationProviderUrl);
errors += CheckForFileTypeSpecificOption("Deployment", "RequiredUpdate", isRequiredUpdateString);
errors += CheckForFileTypeSpecificOption("Deployment", "Install", installString);
errors += CheckForFileTypeSpecificOption("Deployment", "IncludeProviderURL", includeDeploymentProviderUrlString);
errors += CheckForFileTypeSpecificOption("Deployment", "IncludeProviderUrl", includeDeploymentProviderUrlString);
errors += CheckForFileTypeSpecificOption("Deployment", "TrustUrlParameters", trustUrlParametersString);
}

if (Requested(Operations.GenerateDeploymentManifest) ||
Expand Down Expand Up @@ -903,6 +934,7 @@ private bool CheckForInvalidParameters()
errors += CheckForInvalidNonManifestOption("RequiredUpdate", isRequiredUpdateString);
errors += CheckForInvalidNonManifestOption("IncludeProviderURL", includeDeploymentProviderUrlString);
errors += CheckForInvalidNonManifestOption("UseManifestForTrust", useApplicationManifestForTrustInfoString);
errors += CheckForInvalidNonManifestOption("TrustUrlParameters", trustUrlParametersString);
errors += CheckForInvalidNonManifestOption("IconFile", iconFile);
}

Expand Down Expand Up @@ -1321,7 +1353,7 @@ public void ExecuteManifestRelated()
else if (Requested(Operations.GenerateDeploymentManifest))
{
applicationName += ".app";
manifest = Mage.GenerateDeploymentManifest(outputPath, applicationName, applicationVersion, processor, cachedAppManifest, applicationManifestPath, applicationCodeBase, applicationProviderUrl, minVersion, install, includeDeploymentProviderUrl, publisherName, supportUrl, targetFrameworkVersion);
manifest = Mage.GenerateDeploymentManifest(outputPath, applicationName, applicationVersion, processor, cachedAppManifest, applicationManifestPath, applicationCodeBase, applicationProviderUrl, minVersion, install, includeDeploymentProviderUrl, publisherName, supportUrl, targetFrameworkVersion, trustUrlParameters);
}

// Update operations
Expand All @@ -1332,7 +1364,7 @@ public void ExecuteManifestRelated()
}
else if (Requested(Operations.UpdateDeploymentManifest))
{
Mage.UpdateDeploymentManifest(cachedDepManifest, outputPath, applicationName, applicationVersion, processor, cachedAppManifest, applicationManifestPath, applicationCodeBase, applicationProviderUrl, minVersion, install, includeDeploymentProviderUrl, publisherName, supportUrl, targetFrameworkVersion);
Mage.UpdateDeploymentManifest(cachedDepManifest, outputPath, applicationName, applicationVersion, processor, cachedAppManifest, applicationManifestPath, applicationCodeBase, applicationProviderUrl, minVersion, install, includeDeploymentProviderUrl, publisherName, supportUrl, targetFrameworkVersion, trustUrlParameters);
manifest = cachedDepManifest;
}

Expand Down
14 changes: 11 additions & 3 deletions src/clickonce/MageCLI/Mage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,13 @@ public static ApplicationManifest GenerateApplicationManifest(List<string> files
/// <param name="publisherName">Publisher name</param>
/// <param name="supportUrl">Support URL</param>
/// <param name="targetFrameworkVersion">Target Framework version</param>
/// <param name="trustUrlParameters">Specifies if URL parameters should be trusted</param>
/// <returns>DeploymentManifest object</returns>
public static DeployManifest GenerateDeploymentManifest(string deploymentManifestPath,
string appName, Version version, Processors processor,
ApplicationManifest applicationManifest, string applicationManifestPath, string appCodeBase,
string appProviderUrl, string minVersion, TriStateBool install, TriStateBool includeDeploymentProviderUrl,
string publisherName, string supportUrl, string targetFrameworkVersion)
string publisherName, string supportUrl, string targetFrameworkVersion, TriStateBool trustUrlParameters)
{
/*
Mage running on Core cannot obtain .NET FX version for targeting.
Expand Down Expand Up @@ -167,7 +168,7 @@ public static DeployManifest GenerateDeploymentManifest(string deploymentManifes

UpdateDeploymentManifest(manifest, deploymentManifestPath, appName, version, processor,
applicationManifest, applicationManifestPath, appCodeBase,
appProviderUrl, minVersion, install, includeDeploymentProviderUrl, publisherName, supportUrl, targetFrameworkVersion);
appProviderUrl, minVersion, install, includeDeploymentProviderUrl, publisherName, supportUrl, targetFrameworkVersion, trustUrlParameters);

return manifest;
}
Expand Down Expand Up @@ -317,13 +318,15 @@ public static void UpdateApplicationManifest(List<string> filesToIgnore, Applica
/// <param name="publisherName">Publisher name</param>
/// <param name="supportUrl">Support URL</param>
/// <param name="targetFrameworkVersion">Target Framework version</param>
/// <param name="trustUrlParameters">Specifies if URL parameters should be trusted</param>
public static void UpdateDeploymentManifest(DeployManifest manifest, string deploymentManifestPath,
string appName, Version version, Processors processor,
ApplicationManifest applicationManifest, string applicationManifestPath,
string appCodeBase, string appProviderUrl, string minVersion,
TriStateBool install,
TriStateBool includeDeploymentProviderUrl,
string publisherName, string supportUrl, string targetFrameworkVersion)
string publisherName, string supportUrl, string targetFrameworkVersion,
TriStateBool trustUrlParameters)
{
if (install != TriStateBool.Undefined)
{
Expand Down Expand Up @@ -430,6 +433,11 @@ public static void UpdateDeploymentManifest(DeployManifest manifest, string depl
{
SetApplicationCodeBase(manifest, appCodeBase);
}

if (trustUrlParameters == TriStateBool.True)
{
manifest.TrustUrlParameters = true;
}
}

/// <summary>
Expand Down
13 changes: 11 additions & 2 deletions src/clickonce/MageCLI/xlf/Application.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,12 @@ Options
-TimeStampUri &lt;uri&gt; -ti
-ToFile &lt;file_name&gt; -t
-TrustLevel &lt;level&gt; -tr
-TrustURLParameters &lt;true|false&gt; -tu
-UseManifestForTrust &lt;true|false&gt; -um
-Version &lt;version&gt; -v

Use "mage -help verbose" for more detailed help</source>
<target state="translated">Příkazy
<target state="needs-review-translation">Příkazy
-New &lt;typ_souboru&gt; -n
-Update &lt;název_souboru&gt; -u
-Sign &lt;název_souboru&gt; -s
Expand Down Expand Up @@ -333,6 +334,9 @@ Options:
Example:
-TrustLevel FullTrust

-TrustURLParameters &lt;true|false&gt; -tu
Specifies if URL parameters will be trusted and passed to the application.

-UseManifestForTrust &lt;true|false&gt; -um
Specifies if the application manifest will be used for certification and
branding information.
Expand All @@ -342,7 +346,7 @@ Options:
generated or updated. Must be of the form "0.0.0.0".
Example:
-Version 1.2.3.2112</source>
<target state="translated">Příkazy:
<target state="needs-review-translation">Příkazy:

-New &lt;typ_souboru&gt; -n
Vygeneruje nový manifest aplikace, manifest nasazení nebo
Expand Down Expand Up @@ -654,6 +658,11 @@ Možnosti:
<target state="translated">Neplatná úroveň důvěryhodnosti, je třeba zadat hodnotu LocalIntranet, Internet nebo FullTrust – {0}</target>
<note />
</trans-unit>
<trans-unit id="InvalidTrustURLParameters">
<source>The -TrustURLParameters option must be "true", "false", "t", or "f" - "{0}"</source>
<target state="new">The -TrustURLParameters option must be "true", "false", "t", or "f" - "{0}"</target>
<note />
</trans-unit>
<trans-unit id="InvalidUrl">
<source>The URL is not of the proper format - "{0}"</source>
<target state="translated">Adresa URL nemá správný formát – {0}</target>
Expand Down
13 changes: 11 additions & 2 deletions src/clickonce/MageCLI/xlf/Application.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,12 @@ Options
-TimeStampUri &lt;uri&gt; -ti
-ToFile &lt;file_name&gt; -t
-TrustLevel &lt;level&gt; -tr
-TrustURLParameters &lt;true|false&gt; -tu
-UseManifestForTrust &lt;true|false&gt; -um
-Version &lt;version&gt; -v

Use "mage -help verbose" for more detailed help</source>
<target state="translated">Befehle
<target state="needs-review-translation">Befehle
-New &lt;Dateiname&gt; -n
-Update &lt;Dateiname&gt; -u
-Sign &lt;Dateiname&gt; -s
Expand Down Expand Up @@ -333,6 +334,9 @@ Options:
Example:
-TrustLevel FullTrust

-TrustURLParameters &lt;true|false&gt; -tu
Specifies if URL parameters will be trusted and passed to the application.

-UseManifestForTrust &lt;true|false&gt; -um
Specifies if the application manifest will be used for certification and
branding information.
Expand All @@ -342,7 +346,7 @@ Options:
generated or updated. Must be of the form "0.0.0.0".
Example:
-Version 1.2.3.2112</source>
<target state="translated">Befehle:
<target state="needs-review-translation">Befehle:

-New &lt;Dateityp&gt; -n
Hiermit wird unter Verwendung der nachstehend aufgeführten Optionen ein neues Anwendungsmanifest,
Expand Down Expand Up @@ -654,6 +658,11 @@ Optionen:
<target state="translated">Ungültige Vertrauensebene, muss "LocalIntranet", "Internet" oder "FullTrust" lauten: "{0}"</target>
<note />
</trans-unit>
<trans-unit id="InvalidTrustURLParameters">
<source>The -TrustURLParameters option must be "true", "false", "t", or "f" - "{0}"</source>
<target state="new">The -TrustURLParameters option must be "true", "false", "t", or "f" - "{0}"</target>
<note />
</trans-unit>
<trans-unit id="InvalidUrl">
<source>The URL is not of the proper format - "{0}"</source>
<target state="translated">Die URL liegt nicht im richtigen Format vor: "{0}"</target>
Expand Down
Loading