Ejemplo n.º 1
0
        /// <summary>
        /// Gets the path of the specified <see cref="SpecialDirectory"/>
        /// </summary>
        public static string GetDirectoryPath(SpecialDirectory directory)
        {
            switch (directory)
            {
            case SpecialDirectory.ApplicationRootDirectory:
                return(IsInstalled
                        ? Path.GetFullPath(Path.Combine(GetEntryAssemblyDirectory(), "..")).TrimEnd(Path.DirectorySeparatorChar)
                        : GetEntryAssemblyDirectory());

            case SpecialDirectory.CurrentVersionRootDirectory:
                return(GetEntryAssemblyDirectory());

            default:
                throw new NotImplementedException($"Unimplemented case in switch-Statement: {nameof(SpecialDirectory)}.{directory}");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a step to the installer that creates a new batch-file at the specified location with the specified command
        /// </summary>
        /// <param name="directory">The directory to create the batch-file in</param>
        /// <param name="fileName">The file name of the batch file</param>
        /// <param name="command">The command that is to be executed by the batch file</param>
        /// <returns></returns>
        public InstallerBuilder CreateBatchFile(SpecialDirectory directory, string fileName, string command)
        {
            if (string.IsNullOrWhiteSpace(fileName))
            {
                throw new ArgumentException("Value must not be null or empty", nameof(fileName));
            }

            if (string.IsNullOrWhiteSpace(command))
            {
                throw new ArgumentException("Value must not be null or empty", nameof(command));
            }

            m_Steps.AddLast(
                new CreateBatchFileInstallerStep(
                    () => Path.Combine(ApplicationInfo.GetDirectoryPath(directory), fileName),
                    command));
            return(this);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds a step that adds the specified directory to the user's PATH environment variable to the installer
 /// </summary>
 public InstallerBuilder AddDirectoryToPath(SpecialDirectory directory)
 {
     m_Steps.AddLast(new AddDirectoryToPathInstallerStep(() => ApplicationInfo.GetDirectoryPath(directory)));
     return(this);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Saves the specified embedded resource to a file
        /// </summary>
        /// <param name="resourceAssembly">The assembly that contains the resource</param>
        /// <param name="resourceName">The name of the resource </param>
        /// <param name="directory">The directory to place the file in</param>
        /// <param name="fileName">The name of the file the resource will be written to</param>
        /// <param name="overwriteOnUpdate">Specifies whether the file should be overwritten with the resource contents during application updates</param>
        /// <returns></returns>
        public InstallerBuilder SaveResourceToFile(Assembly resourceAssembly, string resourceName, SpecialDirectory directory, string fileName, bool overwriteOnUpdate)
        {
            if (resourceAssembly == null)
            {
                throw new ArgumentNullException(nameof(resourceAssembly));
            }

            if (string.IsNullOrWhiteSpace(resourceName))
            {
                throw new ArgumentException("Value must not be null or empty", nameof(resourceName));
            }

            if (string.IsNullOrWhiteSpace(fileName))
            {
                throw new ArgumentException("Value must not be null or empty", nameof(fileName));
            }


            m_Steps.AddLast(
                new SaveResourceToFileInstallerStep(
                    resourceAssembly,
                    resourceName,
                    () => Path.Combine(ApplicationInfo.GetDirectoryPath(directory), fileName),
                    overwriteOnUpdate));
            return(this);
        }