Avoid path too long errors when performing BuildV2 builds in MVC repo

- do not glob to the ends of the earth when looking for `project.json` files

nits:
- remove unused variable in `_kpm-build.shade`
- remove incorrect comment in `_kpm-pack.shade`
- clean up some trailing whitespace
This commit is contained in:
Doug Bunting 2015-09-18 13:08:32 -07:00
parent a3d943197a
commit cb3dea63a3
3 changed files with 43 additions and 39 deletions

View File

@ -36,7 +36,7 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json'
Configuration = "Debug"; Configuration = "Debug";
E("Configuration", Configuration); E("Configuration", Configuration);
} }
Log.Info("Build v2: " + IsBuildV2); Log.Info("Build v2: " + IsBuildV2);
} }
@ -105,7 +105,7 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json'
{ {
projectFiles.ForEach(projectFile => DnuPack(projectFile, BUILD_DIR, Configuration)); projectFiles.ForEach(projectFile => DnuPack(projectFile, BUILD_DIR, Configuration));
} }
foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR, "*/*.nupkg"))) foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR, "*/*.nupkg")))
{ {
File.Copy(nupkg, Path.Combine(BUILD_DIR, Path.GetFileName(nupkg)), true); File.Copy(nupkg, Path.Combine(BUILD_DIR, Path.GetFileName(nupkg)), true);
@ -115,31 +115,38 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json'
#build-compile target='compile' if='IsBuildV2' #build-compile target='compile' if='IsBuildV2'
@{ @{
// If the src folder, build and create the packages // If the src folder, build and create the packages
if (Directory.Exists("src")) if (Directory.Exists("src"))
{ {
DnuPack("src/**", BUILD_DIR, Configuration); // Handle projects 1 to 3 levels down from src/, avoiding path too long errors.
DnuPack("src/*;src/*/*;src/*/*/*", BUILD_DIR, Configuration);
foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR, "*/*.nupkg"))) foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR, "*/*.nupkg")))
{ {
File.Copy(nupkg, Path.Combine(BUILD_DIR, Path.GetFileName(nupkg)), true); File.Copy(nupkg, Path.Combine(BUILD_DIR, Path.GetFileName(nupkg)), true);
} }
} }
// For test and samples only check if they compile // For test and samples only check if they compile
var projectsToBuild = new List<string>(); var projectsToBuild = new List<string>();
if (Directory.Exists("test")) if (Directory.Exists("test"))
{ {
projectsToBuild.Add("test/**"); // Handle projects 1 to 3 levels down from test/, avoiding path too long errors.
projectsToBuild.Add("test/*");
projectsToBuild.Add("test/*/*");
projectsToBuild.Add("test/*/*/*");
} }
if (Directory.Exists("samples")) if (Directory.Exists("samples"))
{ {
projectsToBuild.Add("samples/**"); // Handle projects 1 to 3 levels down from samples/, avoiding path too long errors.
projectsToBuild.Add("samples/*");
projectsToBuild.Add("samples/*/*");
projectsToBuild.Add("samples/*/*/*");
} }
if (projectsToBuild.Any()) if (projectsToBuild.Any())
{ {
DnuBuild( DnuBuild(
string.Join(";", projectsToBuild), string.Join(";", projectsToBuild),
Configuration); Configuration);
} }
} }
@ -352,7 +359,7 @@ macro name="DnuBuild" projectFile='string' configuration='string'
macro name="DnuPack" projectFile='string' kpmPackOutputDir='string' configuration='string' macro name="DnuPack" projectFile='string' kpmPackOutputDir='string' configuration='string'
kpm-pack kpm-pack
macro name="DeleteFolder" delete='string' macro name="DeleteFolder" delete='string'
directory directory

View File

@ -17,10 +17,9 @@ default build_options='${E("NUGET3_build_options")}'
if (IsBuildV2) if (IsBuildV2)
{ {
var projectsToPack = new List<string>(); var projectsToPack = new List<string>();
foreach(var arg in projectFile.Split((char)';')) foreach(var arg in projectFile.Split((char)';'))
{ {
if (!arg.Contains("*")) if (!arg.Contains("*"))
{ {
projectsToPack.Add(Path.GetDirectoryName(arg)); projectsToPack.Add(Path.GetDirectoryName(arg));
} }
@ -30,15 +29,15 @@ default build_options='${E("NUGET3_build_options")}'
projectsToPack.AddRange(projectFolders); projectsToPack.AddRange(projectFolders);
} }
} }
foreach(var projFolder in projectsToPack) foreach(var projFolder in projectsToPack)
{ {
DeleteFolder(Path.Combine(projFolder, "bin", configuration)); DeleteFolder(Path.Combine(projFolder, "bin", configuration));
} }
var projectsArg=projectFile.Replace(";", " "); var projectsArg=projectFile.Replace(";", " ");
var dnuArgs=string.Format("build{0} {1} --configuration {2}", build_options, projectsArg, configuration); var dnuArgs=string.Format("build{0} {1} --configuration {2}", build_options, projectsArg, configuration);
if (!IsMono) if (!IsMono)
{ {
Exec("cmd", "/C dnu " + dnuArgs); Exec("cmd", "/C dnu " + dnuArgs);
} }
@ -50,13 +49,12 @@ default build_options='${E("NUGET3_build_options")}'
else else
{ {
var projectFolder=Path.GetDirectoryName(projectFile); var projectFolder=Path.GetDirectoryName(projectFile);
var projectName=Path.GetFileName(projectFolder);
var projectBin=Path.Combine(projectFolder, "bin", configuration); var projectBin=Path.Combine(projectFolder, "bin", configuration);
DeleteFolder(projectBin); DeleteFolder(projectBin);
var dnuArgs=string.Format("build{0} {1} --configuration {2}", build_options, projectFolder, configuration); var dnuArgs=string.Format("build{0} {1} --configuration {2}", build_options, projectFolder, configuration);
if (!IsMono) if (!IsMono)
{ {
Exec("cmd", "/C dnu " + dnuArgs); Exec("cmd", "/C dnu " + dnuArgs);
} }

View File

@ -1,7 +1,7 @@
@{/* @{/*
kpm-pack kpm-pack
Builds package from project. Downloads and executes k sdk tools. Builds package from project.
projectFile='' projectFile=''
Required. Path to the project.json to build. Required. Path to the project.json to build.
@ -20,10 +20,9 @@ default pack_options='${E("NUGET3_pack_options")}'
if (IsBuildV2) if (IsBuildV2)
{ {
var projectsToPack = new List<string>(); var projectsToPack = new List<string>();
foreach(var arg in projectFile.Split((char)';')) foreach(var arg in projectFile.Split((char)';'))
{ {
if (!arg.Contains("*")) if (!arg.Contains("*"))
{ {
projectsToPack.Add(Path.GetDirectoryName(arg)); projectsToPack.Add(Path.GetDirectoryName(arg));
} }
@ -34,14 +33,14 @@ default pack_options='${E("NUGET3_pack_options")}'
} }
} }
foreach(var projFolder in projectsToPack) foreach(var projFolder in projectsToPack)
{ {
DeleteFolder(Path.Combine(projFolder, "bin", configuration)); DeleteFolder(Path.Combine(projFolder, "bin", configuration));
} }
var projectsArg=projectFile.Replace(";", " "); var projectsArg=projectFile.Replace(";", " ");
var dnuArgs=string.Format("pack{0} {1} --configuration {2}", pack_options, projectsArg, configuration); var dnuArgs=string.Format("pack{0} {1} --configuration {2}", pack_options, projectsArg, configuration);
if (!IsMono) if (!IsMono)
{ {
Exec("cmd", "/C dnu " + dnuArgs); Exec("cmd", "/C dnu " + dnuArgs);
} }
@ -49,11 +48,11 @@ default pack_options='${E("NUGET3_pack_options")}'
{ {
Exec("dnu", dnuArgs); Exec("dnu", dnuArgs);
} }
foreach(var projFolder in projectsToPack) foreach(var projFolder in projectsToPack)
{ {
CopyFolder( CopyFolder(
Path.Combine(projFolder, "bin", configuration), Path.Combine(projFolder, "bin", configuration),
Path.Combine(kpmPackOutputDir, Path.GetFileName(projFolder)), Path.Combine(kpmPackOutputDir, Path.GetFileName(projFolder)),
true); true);
} }
@ -63,11 +62,11 @@ default pack_options='${E("NUGET3_pack_options")}'
var projectFolder=Path.GetDirectoryName(projectFile); var projectFolder=Path.GetDirectoryName(projectFile);
var projectName=Path.GetFileName(projectFolder); var projectName=Path.GetFileName(projectFolder);
var projectBin=Path.Combine(projectFolder, "bin", configuration); var projectBin=Path.Combine(projectFolder, "bin", configuration);
DeleteFolder(projectBin); DeleteFolder(projectBin);
var dnuArgs=string.Format("pack{0} {1} --configuration {2}", pack_options, projectFolder, configuration); var dnuArgs=string.Format("pack{0} {1} --configuration {2}", pack_options, projectFolder, configuration);
if (!IsMono) if (!IsMono)
{ {
Exec("cmd", "/C dnu " + dnuArgs); Exec("cmd", "/C dnu " + dnuArgs);
} }