| 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 | namespace WixToolset.Harvesters.Data |
| 4 | { |
| 5 | using System; |
| 6 | using System.Resources; |
| 7 | using WixToolset.Data; |
| 8 | |
| 9 | #pragma warning disable 1591 // TODO: add documentation |
| 10 | public static class HarvesterErrors |
| 11 | { |
| 12 | public static Message ArgumentRequiresValue(string argument) |
| 13 | { |
| 14 | return Message(null, Ids.ArgumentRequiresValue, "The argument '{0}' does not have a value specified and it is required.", argument); |
| 15 | } |
| 16 | |
| 17 | public static Message BuildErrorDuringHarvesting(string buildError) |
| 18 | { |
| 19 | return Message(null, Ids.BuildErrorDuringHarvesting, "Build error during harvesting: {0}", buildError); |
| 20 | } |
| 21 | |
| 22 | public static Message BuildFailed() |
| 23 | { |
| 24 | return Message(null, Ids.BuildFailed, "Build failed."); |
| 25 | } |
| 26 | |
| 27 | public static Message CannotBuildProject(string projectFile, string innerExceptionMessage) |
| 28 | { |
| 29 | return Message(null, Ids.CannotBuildProject, "Failed to build project {0}: {1}", projectFile, innerExceptionMessage); |
| 30 | } |
| 31 | |
| 32 | public static Message CannotHarvestWebSite() |
| 33 | { |
| 34 | return Message(null, Ids.CannotHarvestWebSite, "Cannot harvest website. On Windows Vista, you must install IIS 6 Management Compatibility."); |
| 35 | } |
| 36 | |
| 37 | public static Message CannotLoadMSBuildAssembly(string innerExceptionMessage) |
| 38 | { |
| 39 | return Message(null, Ids.CannotLoadMSBuildAssembly, "Failed to load MSBuild assembly: {0}", innerExceptionMessage); |
| 40 | } |
| 41 | |
| 42 | public static Message CannotLoadMSBuildEngine(string innerExceptionMessage) |
| 43 | { |
| 44 | return Message(null, Ids.CannotLoadMSBuildEngine, "Failed to load MSBuild engine: {0}", innerExceptionMessage); |
| 45 | } |
| 46 | |
| 47 | public static Message CannotLoadMSBuildWrapperAssembly(string innerExceptionMessage) |
| 48 | { |
| 49 | return Message(null, Ids.CannotLoadMSBuildWrapperAssembly, "Failed to load MSBuild wrapper assembly: {0}", innerExceptionMessage); |
| 50 | } |
| 51 | |
| 52 | public static Message CannotLoadMSBuildWrapperObject(string innerExceptionMessage) |
| 53 | { |
| 54 | return Message(null, Ids.CannotLoadMSBuildWrapperObject, "Failed to load MSBuild wrapper object: {0}", innerExceptionMessage); |
| 55 | } |
| 56 | |
| 57 | public static Message CannotLoadMSBuildWrapperType(string innerExceptionMessage) |
| 58 | { |
| 59 | return Message(null, Ids.CannotLoadMSBuildWrapperType, "Failed to load MSBuild wrapper type: {0}", innerExceptionMessage); |
| 60 | } |
| 61 | |
| 62 | public static Message CannotLoadProject(string projectFile, string innerExceptionMessage) |
| 63 | { |
| 64 | return Message(null, Ids.CannotLoadProject, "Failed to load project {0}: {1}", projectFile, innerExceptionMessage); |
| 65 | } |
| 66 | |
| 67 | public static Message DirectoryAttributeAccessorBadType(string attributeName) |
| 68 | { |
| 69 | return Message(null, Ids.DirectoryAttributeAccessorBadType, "DirectoryAttributeAccessor tried to access an invalid element type for attribute '{0'}.", attributeName); |
| 70 | } |
| 71 | |
| 72 | public static Message DirectoryNotFound(string directory) |
| 73 | { |
| 74 | return Message(null, Ids.DirectoryNotFound, "The directory '{0}' could not be found.", directory); |
| 75 | } |
| 76 | |
| 77 | public static Message EmptyDirectory(string directory) |
| 78 | { |
| 79 | return Message(null, Ids.EmptyDirectory, "The directory '{0}' did not contain any files or sub-directories and since empty directories are not being kept, there was nothing to harvest.", directory); |
| 80 | } |
| 81 | |
| 82 | public static Message ErrorTransformingHarvestedWiX(string transform, string message) |
| 83 | { |
| 84 | return Message(null, Ids.ErrorTransformingHarvestedWiX, "Error applying transform {0} to harvested WiX: {1}", transform, message); |
| 85 | } |
| 86 | |
| 87 | public static Message FileNotFound(string file) |
| 88 | { |
| 89 | return Message(null, Ids.FileNotFound, "The file '{0}' cannot be found.", file); |
| 90 | } |
| 91 | |
| 92 | public static Message InsufficientPermissionHarvestWebSite() |
| 93 | { |
| 94 | return Message(null, Ids.InsufficientPermissionHarvestWebSite, "Not enough permissions to harvest website. On Windows Vista, you must run Heat elevated."); |
| 95 | } |
| 96 | |
| 97 | public static Message InvalidDirectoryId(string generateType) |
| 98 | { |
| 99 | return Message(null, Ids.InvalidDirectoryId, "Invalid directory ID: {0}. Check that it doesn't start with a hyphen or slash.", generateType); |
| 100 | } |
| 101 | |
| 102 | public static Message InvalidDirectoryOutputType(string generateType) |
| 103 | { |
| 104 | return Message(null, Ids.InvalidOutputType, "Invalid generated type: {0}. Must be one of: components, payloadgroup.", generateType); |
| 105 | } |
| 106 | |
| 107 | public static Message InvalidOutputGroup(string outputGroup) |
| 108 | { |
| 109 | return Message(null, Ids.InvalidOutputGroup, "Invalid project output group: {0}.", outputGroup); |
| 110 | } |
| 111 | |
| 112 | public static Message InvalidProjectOutputType(string generateType) |
| 113 | { |
| 114 | return Message(null, Ids.InvalidOutputType, "Invalid generated type: {0}. Must be one of: components, container, payloadgroup, packagegroup.", generateType); |
| 115 | } |
| 116 | |
| 117 | public static Message InvalidProjectName(string generateType) |
| 118 | { |
| 119 | return Message(null, Ids.InvalidProjectName, "Invalid project name: {0}. Check that it doesn't start with a hyphen or slash.", generateType); |
| 120 | } |
| 121 | |
| 122 | public static Message MissingProjectOutputGroup(string projectFile, string outputGroup) |
| 123 | { |
| 124 | return Message(null, Ids.MissingProjectOutputGroup, "Missing project output group '{1}' in project {0}.", projectFile, outputGroup); |
| 125 | } |
| 126 | |
| 127 | public static Message MsbuildBinPathRequired(string version) |
| 128 | { |
| 129 | return Message(null, Ids.MsbuildBinPathRequired, "MSBuildBinPath required for ToolsVersion '{0}'", version); |
| 130 | } |
| 131 | |
| 132 | public static Message NoOutputGroupSpecified() |
| 133 | { |
| 134 | return Message(null, Ids.NoOutputGroupSpecified, "No project output group specified."); |
| 135 | } |
| 136 | |
| 137 | public static Message PerformanceCategoryNotFound(string key) |
| 138 | { |
| 139 | return Message(null, Ids.PerformanceCategoryNotFound, "Performance category '{0}' not found.", key); |
| 140 | } |
| 141 | |
| 142 | public static Message SpacesNotAllowedInArgumentValue(string arg, string value) |
| 143 | { |
| 144 | return Message(null, Ids.SpacesNotAllowedInArgumentValue, "The switch '{0}' does not allow the spaces from the value. Please remove the spaces in from the value: {1}", arg, value); |
| 145 | } |
| 146 | |
| 147 | public static Message UnableToOpenRegistryKey(string key) |
| 148 | { |
| 149 | return Message(null, Ids.UnableToOpenRegistryKey, "Unable to open registry key '{0}'.", key); |
| 150 | } |
| 151 | |
| 152 | public static Message UnsupportedPerformanceCounterType(string key) |
| 153 | { |
| 154 | return Message(null, Ids.UnsupportedPerformanceCounterType, "Unsupported performance counter type '{0}'.", key); |
| 155 | } |
| 156 | |
| 157 | public static Message WebSiteNotFound(string webSiteDescription) |
| 158 | { |
| 159 | return Message(null, Ids.WebSiteNotFound, "The web site '{0}' could not be found. Please check that the web site exists, and that it is spelled correctly (please note, you must use the correct case).", webSiteDescription); |
| 160 | } |
| 161 | |
| 162 | private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) |
| 163 | { |
| 164 | return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); |
| 165 | } |
| 166 | |
| 167 | private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args) |
| 168 | { |
| 169 | return new Message(sourceLineNumber, MessageLevel.Error, (int)id, resourceManager, resourceName, args); |
| 170 | } |
| 171 | |
| 172 | public enum Ids |
| 173 | { |
| 174 | DirectoryNotFound = 5052, |
| 175 | EmptyDirectory = 5053, |
| 176 | ErrorTransformingHarvestedWiX = 5055, |
| 177 | UnableToOpenRegistryKey = 5056, |
| 178 | SpacesNotAllowedInArgumentValue = 5057, |
| 179 | ArgumentRequiresValue = 5058, |
| 180 | FileNotFound = 5059, |
| 181 | PerformanceCategoryNotFound = 5060, |
| 182 | UnsupportedPerformanceCounterType = 5061, |
| 183 | WebSiteNotFound = 5158, |
| 184 | InsufficientPermissionHarvestWebSite = 5159, |
| 185 | CannotHarvestWebSite = 5160, |
| 186 | InvalidOutputGroup = 5301, |
| 187 | NoOutputGroupSpecified = 5302, |
| 188 | CannotLoadMSBuildAssembly = 5303, |
| 189 | CannotLoadMSBuildEngine = 5304, |
| 190 | CannotLoadProject = 5305, |
| 191 | CannotBuildProject = 5306, |
| 192 | BuildFailed = 5307, |
| 193 | MissingProjectOutputGroup = 5308, |
| 194 | DirectoryAttributeAccessorBadType = 5309, |
| 195 | InvalidOutputType = 5310, |
| 196 | InvalidDirectoryId = 5311, |
| 197 | InvalidProjectName = 5312, |
| 198 | BuildErrorDuringHarvesting = 5313, |
| 199 | CannotLoadMSBuildWrapperAssembly = 5314, |
| 200 | CannotLoadMSBuildWrapperType = 5315, |
| 201 | CannotLoadMSBuildWrapperObject = 5316, |
| 202 | MsbuildBinPathRequired = 5317, |
| 203 | } |
| 204 | } |
| 205 | } |