Example #1
0
        private static void AfterProcess(object sender, CompileFileEventArgs e)
        {
            if (!e.Config.IncludeInProject)
            {
                return;
            }

            var item = _dte.Solution.FindProjectItem(e.Config.FileName);

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

            string input  = e.Config.GetAbsoluteInputFile();
            string output = e.Config.GetAbsoluteOutputFile();

            string inputWithOutputExtension = Path.ChangeExtension(input, Path.GetExtension(output));

            if (inputWithOutputExtension.Equals(output, StringComparison.OrdinalIgnoreCase))
            {
                var inputItem = _dte.Solution.FindProjectItem(input);

                if (inputItem != null)
                {
                    ProjectHelpers.AddNestedFile(input, output);
                }
            }
            else
            {
                item.ContainingProject.AddFileToProject(e.Config.GetAbsoluteOutputFile());
            }
        }
Example #2
0
        private static void AfterProcess(object sender, CompileFileEventArgs e)
        {
            if (!e.Config.IncludeInProject || !e.ContainsChanges)
            {
                return;
            }

            var item = _dte.Solution.FindProjectItem(e.Config.FileName);

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

            FileInfo input  = e.Config.GetAbsoluteInputFile();
            FileInfo output = e.Config.GetAbsoluteOutputFile();

            string inputWithOutputExtension = Path.ChangeExtension(input.FullName, output.Extension);

            if (output.Name.EndsWith(".es5.js"))
            {
                inputWithOutputExtension = Path.ChangeExtension(inputWithOutputExtension, ".es5.js");
            }

            if (inputWithOutputExtension.Equals(output.FullName, StringComparison.OrdinalIgnoreCase))
            {
                var inputItem  = _dte.Solution.FindProjectItem(input.FullName);
                var outputItem = _dte.Solution.FindProjectItem(output.FullName);

                // Only add output file to project if it isn't already
                if (inputItem != null && outputItem == null)
                {
                    ProjectHelpers.AddNestedFile(input.FullName, output.FullName);
                }
            }
            else
            {
                item.ContainingProject.AddFileToProject(e.Config.GetAbsoluteOutputFile().FullName);
            }
        }