FileInfo GetLastUpdateTimeStampFile() { var path = Path.Combine(ApplicationInfo.GetDirectoryPath(SpecialDirectory.ApplicationRootDirectory), s_LastUpdateTimeStampFileName); var fileInfo = new FileInfo(path); return(fileInfo); }
private InstallerBuilder() { // InstallationFlagFileInstallerStep has to be the first step // because ApplicationInfo depends on it to determine the application // root directory m_Steps.AddFirst(new InstallationFlagFileInstallerStep()); // Squirrel catches all exceptions thrown by install events // by default, log exception before Squirrel catches them // this exception handler can be overwritten using the OnException() builder method m_OnException = (Exception e) => { try { using (var stream = File.OpenWrite(Path.Combine(ApplicationInfo.GetDirectoryPath(SpecialDirectory.CurrentVersionRootDirectory), $"Exception_{Guid.NewGuid()}.txt"))) using (var writer = new StreamWriter(stream)) { writer.WriteLine(DateTime.Now); writer.Write(e); } } catch { // ignore } }; }
/// <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); }
/// <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); }
/// <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); }