예제 #1
0
        private async Task UpdateBundleAsync(string bundleFileName, string extension, bool isBuild = false)
        {
            if (_ignoreFolders.Any(p => bundleFileName.Contains("\\" + p + "\\")))
            {
                return;
            }

            try
            {
                BundleDocument doc = await BundleDocument.FromFile(bundleFileName);

                if (doc == null)
                {
                    Logger.Log("Note: Bundle file " + bundleFileName + " is not in Web Essentials bundle format.");
                    return;
                }

                if (!isBuild || doc.RunOnBuild)
                {
                    await GenerateAsync(doc, extension, true);
                }
            }
            catch (FileNotFoundException ex)
            {
                Logger.Log(ex.Message);
                MessageBox.Show("The file '" + Path.GetFileName(ex.Message) + "' does not exist");
                _dte.StatusBar.Text = "Bundle was not created";
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                MessageBox.Show("Error generating the bundle. See output window for details");
            }
        }
예제 #2
0
        private async void SolutionEvents_Opened()
        {
            foreach (Project project in ProjectHelpers.GetAllProjects())
            {
                if (project.ProjectItems.Count == 0)
                {
                    continue;
                }

                string folder = ProjectHelpers.GetRootFolder(project);
                Func <string, bool, Task> bundleFunc = new BundleFilesMenu().UpdateBundleAsync;
                Func <string, bool, Task> spriteFunc = new SpriteImageMenu().UpdateSpriteAsync;

                foreach (string file in Directory.EnumerateFiles(folder, "*.*", SearchOption.AllDirectories)
                         .Where(s => s.EndsWith(".bundle") || s.EndsWith(".sprite")))
                {
                    if (ProjectHelpers.GetProjectItem(file) == null)
                    {
                        continue;
                    }

                    if (file.EndsWith(".bundle", StringComparison.OrdinalIgnoreCase))
                    {
                        await BundleGenerator.WatchFiles(await BundleDocument.FromFile(file), bundleFunc);
                    }
                    else
                    {
                        await SpriteGenerator.WatchFiles(await SpriteDocument.FromFile(file), spriteFunc);
                    }
                }
            }
        }
예제 #3
0
 public async Task <IBundleDocument> LoadFromFile(string fileName)
 {
     return(await BundleDocument.FromFile(fileName));
 }