Skip to content

Commit

Permalink
no longer update the window title and company name
Browse files Browse the repository at this point in the history
  • Loading branch information
YehudaKremer committed Mar 2, 2022
1 parent 17d9554 commit 2730f06
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 44 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 3.3.1

- no longer update the window title and company name in the main.cpp file, to avoid errors when the user has already updated it.

## 3.3.0

- Add `enable-at-startup` configuration and flag, see [Configure your app to start at log-in](https://blogs.windows.com/windowsdeveloper/2017/08/01/configure-app-start-log/).
Expand Down
86 changes: 43 additions & 43 deletions lib/src/windowsBuild.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class WindowsBuild {

/// Run "flutter build windows" command
Future<void> build() async {
var originalRunnerRcContent = await _getRunnerRcContent();
await _updateRunnerCompanyName();
await _updateWindowTitle();
//var originalRunnerRcContent = await _getRunnerRcContent();
//await _updateRunnerCompanyName();
//await _updateWindowTitle();

var buildWindowsArguments = ['build', 'windows'];
if (_config.createWithDebugBuildFiles) buildWindowsArguments.add('--debug');
Expand All @@ -35,58 +35,58 @@ class WindowsBuild {

loggerProgress.finish(showTiming: true);

await _restoreRunnerRcContent(originalRunnerRcContent);
//await _restoreRunnerRcContent(originalRunnerRcContent);
}

Future<String> _getRunnerRcContent() async =>
await File(runnerRcPath).readAsString();
// Future<String> _getRunnerRcContent() async =>
// await File(runnerRcPath).readAsString();

Future<File> _restoreRunnerRcContent(String content) async {
_logger.trace('restore Runner.rc content');
return await File(runnerRcPath).writeAsString(content);
}
// Future<File> _restoreRunnerRcContent(String content) async {
// _logger.trace('restore Runner.rc content');
// return await File(runnerRcPath).writeAsString(content);
// }

/// Update the company name 'com.example' in the Runner.rc file
/// with the [_config.identityName] value.
Future<void> _updateRunnerCompanyName() async {
_logger
.trace('updating Runner.rc "CompanyName" to "${_config.identityName}"');

var runnerRcContentLines = await File(runnerRcPath).readAsLines();
var updatedRunnerRcContent = '';

for (var line in runnerRcContentLines) {
if (line.contains('VALUE "CompanyName"')) {
line =
' VALUE "CompanyName", "${_config.identityName}" "\\0"';
} else if (line.contains('VALUE "LegalCopyright"')) {
line =
' VALUE "LegalCopyright", "Copyright (C) ${DateTime.now().year} ${_config.identityName}. All rights reserved." "\\0"';
}

updatedRunnerRcContent += '$line\n';
}
// Future<void> _updateRunnerCompanyName() async {
// _logger
// .trace('updating Runner.rc "CompanyName" to "${_config.identityName}"');

await File(runnerRcPath).writeAsString(updatedRunnerRcContent);
}
// var runnerRcContentLines = await File(runnerRcPath).readAsLines();
// var updatedRunnerRcContent = '';

// for (var line in runnerRcContentLines) {
// if (line.contains('VALUE "CompanyName"')) {
// line =
// ' VALUE "CompanyName", "${_config.identityName}" "\\0"';
// } else if (line.contains('VALUE "LegalCopyright"')) {
// line =
// ' VALUE "LegalCopyright", "Copyright (C) ${DateTime.now().year} ${_config.identityName}. All rights reserved." "\\0"';
// }

// updatedRunnerRcContent += '$line\n';
// }

// await File(runnerRcPath).writeAsString(updatedRunnerRcContent);
// }

/// Update the app window title in the main.cpp file
/// with the [_config.displayName] value.
Future<void> _updateWindowTitle() async {
_logger.trace('updating main.cpp window title to "${_config.displayName}"');
// Future<void> _updateWindowTitle() async {
// _logger.trace('updating main.cpp window title to "${_config.displayName}"');

var mainCppContentLines = await File(mainCppPath).readAsLines();
var updatedMainCppContent = '';
// var mainCppContentLines = await File(mainCppPath).readAsLines();
// var updatedMainCppContent = '';

for (var line in mainCppContentLines) {
if (line.contains('window.CreateAndShow')) {
line =
'if (!window.CreateAndShow(L"${_config.displayName}", origin, size)) {';
}
// for (var line in mainCppContentLines) {
// if (line.contains('window.CreateAndShow')) {
// line =
// 'if (!window.CreateAndShow(L"${_config.displayName}", origin, size)) {';
// }

updatedMainCppContent += '$line\n';
}
// updatedMainCppContent += '$line\n';
// }

await File(mainCppPath).writeAsString(updatedMainCppContent);
}
// await File(mainCppPath).writeAsString(updatedMainCppContent);
// }
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: msix
description: A command-line tool that create Msix installer from your flutter windows-build files.
version: 3.3.0
version: 3.3.1
maintainer: Yehuda Kremer (yehudakremer@gmail.com)
homepage: https://github.com/YehudaKremer/msix

Expand Down

0 comments on commit 2730f06

Please sign in to comment.