Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.1.0 #7

Merged
merged 5 commits into from
Nov 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.1.0

- add capabilities
- support all tiles sizes
- bug fixes

## 0.0.10

- code refactoring
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ msix_config:
logo_path: C:\<PathToIcon>\<Logo.png>
start_menu_icon_path: C:\<PathToIcon>\<Icon.png>
tile_icon_path: C:\<PathToIcon>\<Icon.png>
icons_background_color: ffffff
icons_background_color: transparent
architecture: x64
capabilities: 'documentsLibrary,internetClient,location,microphone,webcam'
```
tags: `msi` `windows` `win10` `windows10` `windows installer` `windows packaging` `appx` `AppxManifest` `SignTool` `MakeAppx`
5 changes: 3 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ flutter:
#logo_path: C:\<PathToIcon>\<Logo.png>
#start_menu_icon_path: C:\<PathToIcon>\<Icon.png>
#tile_icon_path: C:\<PathToIcon>\<Icon.png>
#icons_background_color: ffffff
#architecture: x64
#icons_background_color: transparent
#architecture: x64
#capabilities: 'documentsLibrary,internetClient,location,microphone,webcam'
23 changes: 17 additions & 6 deletions lib/src/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@ class Configuration {
String appName;
String publisherName;
String identityName;
String msixVersion = '1.0.0.0';
String msixVersion;
String appDescription;
String certificateSubject;
String buildFilesFolder =
'${Directory.current.path}/build/windows/runner/Release';
String certificatePath;
String certificatePassword;
String displayName;
String architecture = 'x64';
String architecture;
String capabilities;
String logoPath;
String startMenuIconPath;
String tileIconPath;
String iconsBackgroundColor = '#ffffff';
bool isUsingTestCertificate = false;
String iconsBackgroundColor;
bool isUseingTestCertificate = false;
String defaultsIconsFolderPath() => '$msixAssetsPath/icons';
String vcLibsFolderPath() => '$msixAssetsPath/VCLibs';
String msixToolkitPath() => '$msixAssetsPath/MSIX-Toolkit';
Expand Down Expand Up @@ -53,6 +54,7 @@ class Configuration {
iconsBackgroundColor =
pubspec['msix_config']['icons_background_color'].toString();
architecture = pubspec['msix_config']['architecture'].toString();
capabilities = pubspec['msix_config']['capabilities'].toString();
}
print(green('done!'));
}
Expand Down Expand Up @@ -89,6 +91,13 @@ class Configuration {
if (isNullOrStringNull(displayName)) displayName = appName;
if (isNullOrStringNull(identityName)) identityName = 'com.flutter.$appName';
if (isNullOrStringNull(publisherName)) publisherName = identityName;
if (isNullOrStringNull(msixVersion)) msixVersion = '1.0.0.0';
if (isNullOrStringNull(architecture)) architecture = 'x64';
if (isNullOrStringNull(capabilities))
capabilities =
'documentsLibrary,internetClient,location,microphone,webcam';
if (isNullOrStringNull(iconsBackgroundColor))
iconsBackgroundColor = 'transparent';

if (!await Directory(buildFilesFolder).exists())
throw (red(
Expand Down Expand Up @@ -124,9 +133,11 @@ class Configuration {
throw (red(
'Architecture can be "x86" or "x64", check "msix_config: architecture" at pubspec.yaml'));

if (!iconsBackgroundColor.contains('#'))
if (iconsBackgroundColor != 'transparent' &&
!iconsBackgroundColor.contains('#'))
iconsBackgroundColor = '#$iconsBackgroundColor';
if (!RegExp(r'^#(?:[0-9a-fA-F]{3}){1,2}$').hasMatch(iconsBackgroundColor))
if (iconsBackgroundColor != 'transparent' &&
!RegExp(r'^#(?:[0-9a-fA-F]{3}){1,2}$').hasMatch(iconsBackgroundColor))
throw (red(
'Icons background color can be only in this format: "#ffffff"'));

Expand Down
93 changes: 86 additions & 7 deletions lib/src/msixFiles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ class MsixFiles {
Future<void> copyIcons() async {
stdout.write(white('copy icons.. '));

/// Use the logo for all icons if they null
if (!isNullOrStringNull(_configuration.logoPath)) {
if (isNullOrStringNull(_configuration.startMenuIconPath))
_configuration.startMenuIconPath = _configuration.logoPath;

if (isNullOrStringNull(_configuration.tileIconPath))
_configuration.tileIconPath = _configuration.logoPath;
}

_configuration.logoPath = await _copyIcon(_configuration.logoPath,
File('${_configuration.defaultsIconsFolderPath()}/icon.png').path);

Expand All @@ -38,14 +47,34 @@ class MsixFiles {
print(green('done!'));
}

bool hasCapability(String capability) => _configuration.capabilities
.split(',')
.map((e) => e.trim().toLowerCase())
.contains(capability.trim().toLowerCase());

Future<void> generateAppxManifest() async {
stdout.write(white('create manifest file.. '));

var manifestContent = '''<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities">
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap2="http://schemas.microsoft.com/appx/manifest/uap/windows10/2"
xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
xmlns:uap4="http://schemas.microsoft.com/appx/manifest/uap/windows10/4"
xmlns:uap6="http://schemas.microsoft.com/appx/manifest/uap/windows10/6"
xmlns:uap7="http://schemas.microsoft.com/appx/manifest/uap/windows10/7"
xmlns:uap8="http://schemas.microsoft.com/appx/manifest/uap/windows10/8"
xmlns:uap10="http://schemas.microsoft.com/appx/manifest/uap/windows10/10"
xmlns:iot="http://schemas.microsoft.com/appx/manifest/iot/windows10"
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
xmlns:desktop2="http://schemas.microsoft.com/appx/manifest/desktop/windows10/2"
xmlns:desktop6="http://schemas.microsoft.com/appx/manifest/desktop/windows10/6"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
xmlns:rescap3="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities/3"
xmlns:rescap6="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities/6"
xmlns:com="http://schemas.microsoft.com/appx/manifest/com/windows10"
xmlns:com2="http://schemas.microsoft.com/appx/manifest/com/windows10/2"
xmlns:com3="http://schemas.microsoft.com/appx/manifest/com/windows10/3">
<Identity Name="${_configuration.identityName}" Version="${_configuration.msixVersion}"
Publisher="${_configuration.certificateSubject.replaceAll(' = ', '=')}" ProcessorArchitecture="x86" />
<Properties>
Expand All @@ -61,13 +90,63 @@ class MsixFiles {
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14316.0" MaxVersionTested="10.0.15063.0" />
</Dependencies>
<Capabilities>
<rescap:Capability Name="runFullTrust"/>
<rescap:Capability Name="runFullTrust" />
${hasCapability('internetClient') ? '<Capability Name="internetClient" />' : ''}
${hasCapability('internetClientServer') ? '<Capability Name="internetClientServer" />' : ''}
${hasCapability('privateNetworkClientServer') ? '<Capability Name="privateNetworkClientServer" />' : ''}
${hasCapability('allJoyn') ? '<Capability Name="allJoyn" />' : ''}
${hasCapability('codeGeneration') ? '<Capability Name="codeGeneration" />' : ''}
${hasCapability('objects3D') ? '<uap:Capability Name="objects3D" />' : ''}
${hasCapability('chat') ? '<uap:Capability Name="chat" />' : ''}
${hasCapability('voipCall') ? '<uap:Capability Name="voipCall" />' : ''}
${hasCapability('voipCall') ? '<uap:Capability Name="voipCall" />' : ''}
${hasCapability('phoneCall') ? '<uap:Capability Name="phoneCall" />' : ''}
${hasCapability('removableStorage') ? '<uap:Capability Name="removableStorage" />' : ''}
${hasCapability('userAccountInformation') ? '<uap:Capability Name="userAccountInformation" />' : ''}
${hasCapability('sharedUserCertificates') ? '<uap:Capability Name="sharedUserCertificates" />' : ''}
${hasCapability('blockedChatMessages') ? '<uap:Capability Name="blockedChatMessages" />' : ''}
${hasCapability('appointments') ? '<uap:Capability Name="appointments" />' : ''}
${hasCapability('contacts') ? '<uap:Capability Name="contacts" />' : ''}
${hasCapability('musicLibrary') ? '<uap:Capability Name="musicLibrary" />' : ''}
${hasCapability('videosLibrary') ? '<uap:Capability Name="videosLibrary" />' : ''}
${hasCapability('picturesLibrary') ? '<uap:Capability Name="picturesLibrary" />' : ''}
${hasCapability('enterpriseAuthentication') ? '<uap:Capability Name="enterpriseAuthentication" />' : ''}
${hasCapability('phoneCallHistoryPublic') ? '<uap2:Capability Name="phoneCallHistoryPublic" />' : ''}
${hasCapability('spatialPerception') ? '<uap2:Capability Name="spatialPerception" />' : ''}
${hasCapability('userNotificationListener') ? '<uap3:Capability Name="userNotificationListener" />' : ''}
${hasCapability('remoteSystem') ? '<uap3:Capability Name="remoteSystem" />' : ''}
${hasCapability('backgroundMediaPlayback') ? '<uap3:Capability Name="backgroundMediaPlayback" />' : ''}
${hasCapability('offlineMapsManagement') ? '<uap4:Capability Name="offlineMapsManagement" />' : ''}
${hasCapability('userDataTasks') ? '<uap4:Capability Name="userDataTasks" />' : ''}
${hasCapability('graphicsCapture') ? '<uap6:Capability Name="graphicsCapture" />' : ''}
${hasCapability('globalMediaControl') ? '<uap7:Capability Name="globalMediaControl" />' : ''}
${hasCapability('gazeInput') ? '<uap7:Capability Name="gazeInput" />' : ''}
${hasCapability('systemManagement') ? '<iot:Capability Name="systemManagement" />' : ''}
${hasCapability('lowLevelDevices') ? '<iot:Capability Name="lowLevelDevices" />' : ''}
${hasCapability('documentsLibrary') ? '<rescap:Capability Name="documentsLibrary" />' : ''}
${hasCapability('accessoryManager') ? '<rescap:Capability Name="accessoryManager" />' : ''}
${hasCapability('allowElevation') ? '<rescap:Capability Name="allowElevation" />' : ''}
${hasCapability('location') ? '<DeviceCapability Name="location" />' : ''}
${hasCapability('microphone') ? '<DeviceCapability Name="microphone" />' : ''}
${hasCapability('webcam') ? '<DeviceCapability Name="webcam" />' : ''}
${hasCapability('radios') ? '<DeviceCapability Name="radios" />' : ''}
</Capabilities>
<Applications>
<Application Id="${_configuration.appName.replaceAll('_', '')}" Executable="${_configuration.appName}.exe" EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements BackgroundColor="${_configuration.iconsBackgroundColor}"
<uap:VisualElements BackgroundColor="${_configuration.iconsBackgroundColor}"
DisplayName="${_configuration.displayName}" Square150x150Logo="${_configuration.tileIconPath}"
Square44x44Logo="${_configuration.startMenuIconPath}" Description="${_configuration.appDescription}" />
Square44x44Logo="${_configuration.startMenuIconPath}" Description="${_configuration.appDescription}" >
<uap:DefaultTile ShortName="${_configuration.displayName}" Square310x310Logo="${_configuration.tileIconPath}"
Square71x71Logo="${_configuration.startMenuIconPath}" Wide310x150Logo="${_configuration.tileIconPath}">
<uap:ShowNameOnTiles>
<uap:ShowOn Tile="square150x150Logo"/>
<uap:ShowOn Tile="square310x310Logo"/>
<uap:ShowOn Tile="wide310x150Logo"/>
</uap:ShowNameOnTiles>
</uap:DefaultTile>
<uap:SplashScreen Image="${_configuration.tileIconPath}"/>
<uap:LockScreen BadgeLogo="${_configuration.tileIconPath}" Notification="badge"/>
</uap:VisualElements>
</Application>
</Applications>
</Package>''';
Expand Down
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: Create and sign Msix installer for flutter windows-build files.
version: 0.0.10
version: 0.1.0
maintainer: Yehuda Kremer ([email protected])
homepage: https://github.com/YehudaKremer/msix

Expand Down