| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
| 2 | |
| 3 | using System; |
| 4 | using System.Diagnostics; |
| 5 | using System.Reflection; |
| 6 | using System.Resources; |
| 7 | |
| 8 | [assembly: AssemblyCompany(".NET Foundation")] |
| 9 | [assembly: AssemblyCopyright("Copyright (c) .NET Foundation and contributors. All rights reserved.")] |
| 10 | [assembly: AssemblyProduct("WiX Toolset")] |
| 11 | |
| 12 | #if DEBUG |
| 13 | [assembly: AssemblyConfiguration("DEBUG")] |
| 14 | #else |
| 15 | [assembly: AssemblyConfiguration("")] |
| 16 | #endif |
| 17 | [assembly: NeutralResourcesLanguage("en-US")] |
| 18 | |
| 19 | namespace WixToolset |
| 20 | { |
| 21 | /// <summary> |
| 22 | /// Distribution specific strings. |
| 23 | /// </summary> |
| 24 | internal static class WixDistribution |
| 25 | { |
| 26 | /// <summary> |
| 27 | /// News URL for the distribution. |
| 28 | /// </summary> |
| 29 | public static string NewsUrl = "http://wixtoolset.org/news/"; |
| 30 | |
| 31 | /// <summary> |
| 32 | /// Short product name for the distribution. |
| 33 | /// </summary> |
| 34 | public static string ShortProduct = "WiX Toolset"; |
| 35 | |
| 36 | /// <summary> |
| 37 | /// Support URL for the distribution. |
| 38 | /// </summary> |
| 39 | public static string SupportUrl = "http://wixtoolset.org/"; |
| 40 | |
| 41 | /// <summary> |
| 42 | /// Telemetry URL format for the distribution. |
| 43 | /// </summary> |
| 44 | public static string TelemetryUrlFormat = "http://wixtoolset.org/integrationtelemetry/v{0}/?r={1}"; |
| 45 | |
| 46 | /// <summary> |
| 47 | /// VS Extensions Landing page Url for the distribution. |
| 48 | /// </summary> |
| 49 | public static string VSExtensionsLandingUrl = "http://wixtoolset.org/releases/"; |
| 50 | |
| 51 | public static string ReplacePlaceholders(string original, Assembly assembly) |
| 52 | { |
| 53 | if (null != assembly) |
| 54 | { |
| 55 | FileVersionInfo fileVersion = FileVersionInfo.GetVersionInfo(assembly.Location); |
| 56 | |
| 57 | original = original.Replace("[FileComments]", fileVersion.Comments); |
| 58 | original = original.Replace("[FileCopyright]", fileVersion.LegalCopyright); |
| 59 | original = original.Replace("[FileProductName]", fileVersion.ProductName); |
| 60 | original = original.Replace("[FileVersion]", fileVersion.FileVersion); |
| 61 | |
| 62 | if (original.Contains("[FileVersionMajorMinor]")) |
| 63 | { |
| 64 | Version version = new Version(fileVersion.FileVersion); |
| 65 | original = original.Replace("[FileVersionMajorMinor]", String.Concat(version.Major, ".", version.Minor)); |
| 66 | } |
| 67 | |
| 68 | AssemblyCompanyAttribute company; |
| 69 | if (WixDistribution.TryGetAttribute(assembly, out company)) |
| 70 | { |
| 71 | original = original.Replace("[AssemblyCompany]", company.Company); |
| 72 | } |
| 73 | |
| 74 | AssemblyCopyrightAttribute copyright; |
| 75 | if (WixDistribution.TryGetAttribute(assembly, out copyright)) |
| 76 | { |
| 77 | original = original.Replace("[AssemblyCopyright]", copyright.Copyright); |
| 78 | } |
| 79 | |
| 80 | AssemblyDescriptionAttribute description; |
| 81 | if (WixDistribution.TryGetAttribute(assembly, out description)) |
| 82 | { |
| 83 | original = original.Replace("[AssemblyDescription]", description.Description); |
| 84 | } |
| 85 | |
| 86 | AssemblyProductAttribute product; |
| 87 | if (WixDistribution.TryGetAttribute(assembly, out product)) |
| 88 | { |
| 89 | original = original.Replace("[AssemblyProduct]", product.Product); |
| 90 | } |
| 91 | |
| 92 | AssemblyTitleAttribute title; |
| 93 | if (WixDistribution.TryGetAttribute(assembly, out title)) |
| 94 | { |
| 95 | original = original.Replace("[AssemblyTitle]", title.Title); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | original = original.Replace("[NewsUrl]", WixDistribution.NewsUrl); |
| 100 | original = original.Replace("[ShortProduct]", WixDistribution.ShortProduct); |
| 101 | original = original.Replace("[SupportUrl]", WixDistribution.SupportUrl); |
| 102 | return original; |
| 103 | } |
| 104 | |
| 105 | private static bool TryGetAttribute<T>(Assembly assembly, out T attribute) where T : Attribute |
| 106 | { |
| 107 | attribute = null; |
| 108 | |
| 109 | object[] customAttributes = assembly.GetCustomAttributes(typeof(T), false); |
| 110 | if (null != customAttributes && 0 < customAttributes.Length) |
| 111 | { |
| 112 | attribute = customAttributes[0] as T; |
| 113 | } |
| 114 | |
| 115 | return null != attribute; |
| 116 | } |
| 117 | } |
| 118 | } |