private void EnsureLibreOffice() { if (!LibreOfficeUtils.IsLibreOfficeOnPath()) { var(found, sofficePath) = LibreOfficeUtils.FindLibreOfficeBinary(); if (found) { var oldValue = Environment.GetEnvironmentVariable("PATH"); var newValue = oldValue + Path.PathSeparator + Path.GetDirectoryName(sofficePath); Environment.SetEnvironmentVariable("PATH", newValue); } else { throw ExitCode.LibreOfficeNotFound().ToCommandException(); } } if (!LibreOfficeUtils.HasLibreOfficeProfile()) { throw ExitCode.NoLibreOfficeProfile(LibreOfficeUtils.ExpectedProfileDir).ToCommandException(); } }