Adding support for debugging sample applications

This commit is contained in:
Pranav K 2014-01-29 18:01:16 -08:00
parent f4e3bb768d
commit 738ab055de
1 changed files with 32 additions and 2 deletions

View File

@ -199,7 +199,13 @@ functions
= String.Join(Environment.NewLine,
BuildFileList(projectDir, "*.cs", "Compile"),
BuildFileList(projectDir, "*.resx", "EmbeddedResource"));
bool isSample = Path.GetDirectoryName(projectDir)
.TrimEnd(Path.DirectorySeparatorChar)
.EndsWith("samples");
Log("Processing sample project '{0}'", projectName);
var packageReferences = dependencies.Where(r => !projectMapping.ContainsKey(r.Key))
.ToDictionary(k => k.Key, k => (string)k.Value);
@ -227,7 +233,11 @@ functions
object specificUnsafeValue = Get<object>(specificCompilationOptions, "allowUnsafe");
bool allowUnsafeCode = unsafeValue == null ? sharedAllowUnsafeCode : (bool)specificUnsafeValue;
string extraProperties = allowUnsafeCode ? "\n<AllowUnsafeBlocks>true</AllowUnsafeBlocks>" : "";
string extraProperties = (allowUnsafeCode ? "\n<AllowUnsafeBlocks>true</AllowUnsafeBlocks>" : "");
if (isSample)
{
extraProperties += GenerateStartupAction(projectDir, projectName, packagesDir, pair.Key);
}
string id = (string)GetObject(projectMapping, projectName)[targetFramework];
@ -308,6 +318,26 @@ functions
.Where(p => !p.StartsWith(@"obj\"))
.Select(p => String.Format(@"<{0} Include=""{1}"" />", elementName, p)));
}
private static string GenerateStartupAction(string projectRoot, string projectName, string packagesDir, string configType)
{
// packages\ProjectK.*\tools\bin\klr.exe 
// packages\ProjectK.*\tools\Microsoft.Net.ApplicationHost\bin\net45\Microsoft.Net.ApplicationHost.dll 
string klrPath = Directory.EnumerateFiles(packagesDir, "klr.exe", SearchOption.AllDirectories).FirstOrDefault();
if (klrPath == null)
{
Warn("Unable to locate klr.exe under packages");
return "";
}
string toolsDir = Path.GetDirectoryName(Path.GetDirectoryName(klrPath));
string outputDll = Path.Combine(projectRoot, "bin", "Debug", configType == "k10" ? "k" : "net45", projectName + ".dll");
return String.Format(@"<StartAction>Program</StartAction>
<StartProgram>{0}</StartProgram>
<StartArguments>{1}</StartArguments>", klrPath, outputDll);
}
private static string GetProjectKTargets(string packagesDir)
{