Beispiel #1
0
        public AppBuildState PrepareCodeBase(AppBuildState state)
        {
            var appBaseDir      = $"./{state.AppCode}";
            var appBuildBaseDir = $"{appBaseDir}/{state.BuildNumber}";

            FileUtils.CopyFiles(_codeBaseDir, $"{appBuildBaseDir}/iOS");
            FileUtils.CopyFile("DDAppNative.Common.dll", $"{appBuildBaseDir}/iOS/DDAppNative.Common.dll");

            return(state);
        }
        public async Task <AppBuildState> BuildLocalCacheAsync(AppBuildState state, IEnumerable <string> cacheList)
        {
            var appBaseDir = $"./{state.AppCode}/{state.BuildNumber}/Caches";

            Directory.CreateDirectory(appBaseDir);
            var applicationCache = new ApplicationCache(_appHostBase.ToString(), appBaseDir);

            var fileCaches         = new List <string>();
            var unsucessfullCaches = new List <string>();

            foreach (var cacheUrl in cacheList)
            {
                try
                {
                    var url      = new Uri(_appHostBase, $"{cacheUrl}").ToString();
                    var fileName = $"Caches{cacheUrl.GetGUID()}";
                    var filePath = $"{appBaseDir}/{fileName}";

                    Console.WriteLine($"{fileName} <== {cacheUrl}");
                    var remoteCache = await applicationCache.CheckRemoteCacheAsync(url, string.Empty).ConfigureAwait(false);

                    if (remoteCache != null)
                    {
                        using (var cache = File.Open(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
                        {
                            var outputStreams = new List <Stream> {
                                cache
                            };

                            await applicationCache.WriteRemoteCacheAsync(remoteCache, cache, outputStreams).ConfigureAwait(false);

                            fileCaches.Add(fileName);
                        }
                    }
                }
                catch
                {
                    unsucessfullCaches.Add(cacheUrl);
                }
            }

            foreach (var url in unsucessfullCaches)
            {
                Console.WriteLine($"Unable to cache {url}");
            }
            state.Caches = fileCaches;

            return(state);
        }
Beispiel #3
0
        public void FillInCode(AppBuildState state)
        {
            var variables = new Dictionary <string, string> {
                { "{{APP_CODE}}", state.AppCode },
                { "{{DISPLAY_NAME}}", state.DisplayName },
                { "{{SERVICE_HOST}}", state.ServiceHost },
                { "{{SERVICE_INITIAL_URL}}", state.ServiceInitialUrl },
                { "{{BUILD_NUMBER}}", state.BuildNumber },
                { "{{APP_VERSION}}", state.AppVersion },
                { "{{BUNDLE_IDENTIFIER}}", state.BundleIdentifier },
                { "{{ONE_SIGNAL_IDENTIFIER}}", state.OneSignalIdentifier },
                { "{{IGNORE_URLS}}", string.Join(',', state.IgnoreUrls.Select(x => $"\"{x}\"")) },
                { "{{CACHES}}", state.Caches.Aggregate(new StringBuilder(), (curr, next) => curr.Append($"\r\n    <BundleResource Include=\"Resources\\{next}\" />")).ToString() }
            };

            var appBaseDir      = $"./{state.AppCode}";
            var appBuildBaseDir = $"{appBaseDir}/{state.BuildNumber}";

            FileUtils.ReplaceInFiles($"{appBuildBaseDir}/iOS", variables);
        }
Beispiel #4
0
        public void FillInResources(AppBuildState state)
        {
            var appBaseDir      = $"./{state.AppCode}";
            var appBuildBaseDir = $"{appBaseDir}/{state.BuildNumber}";

            FileUtils.CopyFiles($"{appBuildBaseDir}/Caches", $"{appBuildBaseDir}/Android/Resources");

            var appResourceDir = $"{_resourcesBaseDir}/{state.AppCode}";
            var appDrawableDir = $"{appBuildBaseDir}/Android/Resources/drawable";

            var resourcePackage = new ImageResourceDefinition[]
            {
                // Drawable
                new ImageResourceDefinition {
                    Source = $"{appResourceDir}/icon_s.png", Destination = $"{appDrawableDir}/icon.png", Width = 40, Height = 40
                },
            };

            var missingResources = resourcePackage.Where(x => !FileUtils.PathExists(x.Source))
                                   .Select(x => $"Resource file is missing [{x.Source}]").ToList();

            foreach (var resource in missingResources)
            {
                Console.WriteLine(resource);
            }

            foreach (var resource in resourcePackage)
            {
                using (var image = Image.Load(resource.Source))
                {
                    image.Mutate(x => x
                                 .Resize(resource.Width, resource.Height));
                    image.Save(resource.Destination);
                }
            }
        }
        public void FillInResources(AppBuildState state)
        {
            var appBaseDir      = $"./{state.AppCode}";
            var appBuildBaseDir = $"{appBaseDir}/{state.BuildNumber}";

            FileUtils.CopyFiles($"{appBuildBaseDir}/Caches", $"{appBuildBaseDir}/iOS/Resources");

            var appResourceDir  = $"{_resourcesBaseDir}/{state.AppCode}";
            var appIconsDir     = $"{appBuildBaseDir}/iOS/Resources/Media.xcassets/AppIcons.appiconset";
            var launchImageDir  = $"{appBuildBaseDir}/iOS/Resources/Media.xcassets/LaunchImage.imageset";
            var launchImagesDir = $"{appBuildBaseDir}/iOS/Resources/Media.xcassets/LaunchImages.launchimage";

            var resourcePackage = new ImageResourceDefinition[]
            {
                // AppIcons
                new ImageResourceDefinition {
                    Source = $"{appResourceDir}/icon_s.png", Destination = $"{appIconsDir}/29x29.png", Width = 29, Height = 29
                },
                new ImageResourceDefinition {
                    Source = $"{appResourceDir}/icon_s.png", Destination = $"{appIconsDir}/40x40.png", Width = 40, Height = 40
                },
                new ImageResourceDefinition {
                    Source = $"{appResourceDir}/icon_s.png", Destination = $"{appIconsDir}/58x58.png", Width = 58, Height = 58
                },
                new ImageResourceDefinition {
                    Source = $"{appResourceDir}/icon_l.png", Destination = $"{appIconsDir}/76x76.png", Width = 76, Height = 76
                },
                new ImageResourceDefinition {
                    Source = $"{appResourceDir}/icon_l.png", Destination = $"{appIconsDir}/80x80.png", Width = 80, Height = 80
                },
                new ImageResourceDefinition {
                    Source = $"{appResourceDir}/icon_l.png", Destination = $"{appIconsDir}/114x114.png", Width = 114, Height = 114
                },
                new ImageResourceDefinition {
                    Source = $"{appResourceDir}/icon_l.png", Destination = $"{appIconsDir}/120x120.png", Width = 120, Height = 120
                },
                new ImageResourceDefinition {
                    Source = $"{appResourceDir}/icon_l.png", Destination = $"{appIconsDir}/152x152.png", Width = 152, Height = 152
                },
                new ImageResourceDefinition {
                    Source = $"{appResourceDir}/icon_l.png", Destination = $"{appIconsDir}/167x167.png", Width = 167, Height = 167
                },
                new ImageResourceDefinition {
                    Source = $"{appResourceDir}/icon_l.png", Destination = $"{appIconsDir}/1024x1024.png", Width = 1024, Height = 1024
                },
                // LaunchImage
                new ImageResourceDefinition {
                    Source = $"{appResourceDir}/splash_screen_l.png", Destination = $"{launchImageDir}/Splash_Screen_640x1136.png", Width = 640, Height = 1136
                },
                // LaunchImages
                new ImageResourceDefinition {
                    Source = $"{appResourceDir}/splash_screen_s.png", Destination = $"{launchImagesDir}/Splash_Screen_320x480.png", Width = 320, Height = 480
                },
                new ImageResourceDefinition {
                    Source = $"{appResourceDir}/splash_screen_l.png", Destination = $"{launchImagesDir}/Splash_Screen_640x960.png", Width = 640, Height = 960
                },
                new ImageResourceDefinition {
                    Source = $"{appResourceDir}/splash_screen_l.png", Destination = $"{launchImagesDir}/Splash_Screen_640x1136.png", Width = 640, Height = 1136
                },
            };

            var missingResources = resourcePackage.Where(x => !FileUtils.PathExists(x.Source))
                                   .Select(x => $"Resource file is missing [{x.Source}]").ToList();

            foreach (var resource in missingResources)
            {
                Console.WriteLine(resource);
            }

            var encoder = new PngEncoder();

            encoder.ColorType = PngColorType.Rgb;

            foreach (var resource in resourcePackage)
            {
                using (var image = Image.Load(resource.Source))
                {
                    image.Mutate(x => x
                                 .Resize(resource.Width, resource.Height));
                    image.Save(resource.Destination, encoder);
                }
            }
        }