diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dada28b..ae6e2e8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ - [ ] Preview window (#6) - [ ] File globbing pattern support (#49) - [ ] Run compilers from a node server -- [x] Updated to Babel 6 compiler +- [x] Set build action to "None" on default file (#159) Features that have a checkmark are complete and available for download in the diff --git a/src/WebCompilerVsix/Commands/CreateConfig.cs b/src/WebCompilerVsix/Commands/CreateConfig.cs index c695b11c..8e05ef03 100644 --- a/src/WebCompilerVsix/Commands/CreateConfig.cs +++ b/src/WebCompilerVsix/Commands/CreateConfig.cs @@ -146,7 +146,7 @@ private void AddConfig(object sender, EventArgs e) string defaultsFile = Path.Combine(folder, Constants.DEFAULTS_FILENAME); ProjectHelpers.CheckFileOutOfSourceControl(defaultsFile); handler.CreateDefaultsFile(defaultsFile); - ProjectHelpers.AddNestedFile(configFile, defaultsFile); + ProjectHelpers.AddNestedFile(configFile, defaultsFile, "None"); WebCompilerPackage._dte.StatusBar.Progress(true, "Creating defaults file", 3, 3); CompilerService.Process(configFile, new[] { config }); diff --git a/src/WebCompilerVsix/Helpers/ProjectHelpers.cs b/src/WebCompilerVsix/Helpers/ProjectHelpers.cs index 60ec3f88..e509ca3a 100644 --- a/src/WebCompilerVsix/Helpers/ProjectHelpers.cs +++ b/src/WebCompilerVsix/Helpers/ProjectHelpers.cs @@ -98,19 +98,27 @@ public static void AddFileToProject(this Project project, string file, string it if (project.IsKind(ProjectTypes.ASPNET_5)) return; + + if (_dte.Solution.FindProjectItem(file) == null) + { + ProjectItem item = project.ProjectItems.AddFromFile(file); + item.SetItemType(itemType); + } + } + + public static void SetItemType(this ProjectItem item, string itemType) + { try { - if (_dte.Solution.FindProjectItem(file) == null) - { - ProjectItem item = project.ProjectItems.AddFromFile(file); + if (item == null || item.ContainingProject == null) + return; - if (string.IsNullOrEmpty(itemType) - || project.IsKind(ProjectTypes.WEBSITE_PROJECT) - || project.IsKind(ProjectTypes.UNIVERSAL_APP)) - return; + if (string.IsNullOrEmpty(itemType) + || item.ContainingProject.IsKind(ProjectTypes.WEBSITE_PROJECT) + || item.ContainingProject.IsKind(ProjectTypes.UNIVERSAL_APP)) + return; - item.Properties.Item("ItemType").Value = "None"; - } + item.Properties.Item("ItemType").Value = itemType; } catch (Exception ex) { @@ -118,7 +126,7 @@ public static void AddFileToProject(this Project project, string file, string it } } - public static void AddNestedFile(string parentFile, string newFile) + public static void AddNestedFile(string parentFile, string newFile, string itemType = null) { ProjectItem item = _dte.Solution.FindProjectItem(parentFile); @@ -137,6 +145,9 @@ public static void AddNestedFile(string parentFile, string newFile) { item.ProjectItems.AddFromFile(newFile); } + + ProjectItem newItem = _dte.Solution.FindProjectItem(newFile); + newItem.SetItemType(itemType); } catch (Exception ex) { @@ -235,5 +246,6 @@ public static class ProjectTypes public const string ASPNET_5 = "{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}"; public const string WEBSITE_PROJECT = "{E24C65DC-7377-472B-9ABA-BC803B73C61A}"; public const string UNIVERSAL_APP = "{262852C6-CD72-467D-83FE-5EEB1973A190}"; + public const string NODE_JS = "{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}"; } }