From a951d40352e73aee213e76aff00e129763acf276 Mon Sep 17 00:00:00 2001 From: anpete Date: Thu, 30 Jan 2014 11:34:26 -0800 Subject: [PATCH] Match k build resource embedding --- build/_k-generate-projects.shade | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/build/_k-generate-projects.shade b/build/_k-generate-projects.shade index bbdbcbf72f..50a25eed3e 100644 --- a/build/_k-generate-projects.shade +++ b/build/_k-generate-projects.shade @@ -194,11 +194,19 @@ functions configs["net45"] = new Dictionary(); } - // Get the list of files - var filesString + // Build the list of cs files + var csFiles = String.Join(Environment.NewLine, - BuildFileList(projectDir, "*.cs", "Compile"), - BuildFileList(projectDir, "*.resx", "EmbeddedResource")); + FindFilesOfType(projectDir, "*.cs") + .Select(p => String.Format(@"", p))); + + // Build the list of resx files + var resxFiles + = String.Join(Environment.NewLine, + FindFilesOfType(projectDir, "*.resx") + .Select(p => String.Format(@" + {1}.{2}.resources +", p, projectName, Path.GetFileNameWithoutExtension(p)))); bool isSample = Path.GetDirectoryName(projectDir) .TrimEnd(Path.DirectorySeparatorChar) @@ -276,7 +284,7 @@ functions .Replace("{Name}", projectName) .Replace("{Defines}", String.Join(";", defines)) .Replace("{ExtraProperties}", extraProperties) - .Replace("{Files}", filesString) + .Replace("{Files}", String.Join(Environment.NewLine, csFiles, resxFiles)) .Replace("{ProjectReferences}", BuildProjectReferences(projectReferences, targetFramework, projectMapping)) .Replace("{References}", BuildReferences(allPackageReferences, gacReferences, packagesDir, targetFramework, GetCandidates(targetFramework))); @@ -310,13 +318,11 @@ functions } } - private static string BuildFileList(string projectDir, string pattern, string elementName) + private static IEnumerable FindFilesOfType(string projectDir, string pattern) { - return String.Join(Environment.NewLine, - Directory.GetFiles(projectDir, pattern, SearchOption.AllDirectories) - .Select(p => p.Substring(projectDir.Length).Trim(Path.DirectorySeparatorChar)) - .Where(p => !p.StartsWith(@"obj\")) - .Select(p => String.Format(@"<{0} Include=""{1}"" />", elementName, p))); + return Directory.GetFiles(projectDir, pattern, SearchOption.AllDirectories) + .Select(p => p.Substring(projectDir.Length).Trim(Path.DirectorySeparatorChar)) + .Where(p => !p.StartsWith(@"obj\")); } private static string GenerateStartupAction(string projectRoot, string projectName, string packagesDir, string configType)