Exemple #1
0
        private void AddConfig(object sender, EventArgs e)
        {
            var question = MessageBox.Show($"This will delete all output files from the project.\r\rDo you want to continue?", Constants.VSIX_NAME, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (question == DialogResult.No)
            {
                return;
            }

            var item = ProjectHelpers.GetSelectedItems().FirstOrDefault();

            if (item == null || item.Properties == null)
            {
                return;
            }

            string configFile = item.Properties.Item("FullPath").Value.ToString();

            var configs = ConfigHandler.GetConfigs(configFile);

            foreach (Config config in configs)
            {
                string outputFile = config.GetAbsoluteOutputFile().FullName;
                ProjectHelpers.DeleteFileFromProject(outputFile);
            }

            Telemetry.TrackEvent("VS clean output files");
        }
 private void Deletefile(string file)
 {
     try
     {
         if (File.Exists(file))
         {
             if (!ProjectHelpers.DeleteFileFromProject(file))
             {
                 BundlerMinifier.FileHelpers.RemoveReadonlyFlagFromFile(file);
                 File.Delete(file);
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Log(ex);
     }
 }
Exemple #3
0
        public bool SaveBindings(string configPath, string bindingsXml)
        {
            string bindingPath = configPath + ".bindings";

            try
            {
                ProjectHelpers.CheckFileOutOfSourceControl(bindingPath);

                if (bindingsXml == "<binding />" && File.Exists(bindingPath))
                {
                    ProjectHelpers.DeleteFileFromProject(bindingPath);
                }
                else
                {
                    File.WriteAllText(bindingPath, "///" + bindingsXml, Encoding.UTF8);
                    ProjectHelpers.AddNestedFile(configPath, bindingPath);
                }

                IVsPersistDocData persistDocData;
                if (!CakePackage.IsDocumentDirty(configPath, out persistDocData) && persistDocData != null)
                {
                    int    cancelled;
                    string newName;
                    persistDocData.SaveDocData(VSSAVEFLAGS.VSSAVE_SilentSave, out newName, out cancelled);
                }
                else if (persistDocData == null)
                {
                    new FileInfo(configPath).LastWriteTime = DateTime.Now;
                }

                return(true);
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                return(false);
            }
        }