Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix .NET Core script generator to correctly handle directories #333

Merged
merged 2 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/BuildScriptGenerator/DotNetCore/DotnetCorePlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,12 @@ public BuildScriptSnippet GenerateBashBuildScriptSnippet(BuildScriptGeneratorCon
.AppendLine("set -e")
.AppendLine()
.AddScriptToCopyToIntermediateDirectory(
sourceDir: sourceDir,
sourceDir: ref sourceDir,
intermediateDir: intermediateDir,
GetDirectoriesToExcludeFromCopyToIntermediateDir(context));
GetDirectoriesToExcludeFromCopyToIntermediateDir(context))
.AppendFormatWithLine("cd \"{0}\"", sourceDir)
.AppendLine();

sourceDir = intermediateDir;
scriptBuilder
.AddScriptToSetupSourceAndDestinationDirectories(
sourceDir: sourceDir,
Expand Down
12 changes: 7 additions & 5 deletions src/BuildScriptGenerator/DotNetCore/ScriptBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static class ScriptBuilderExtensions
{
public static StringBuilder AddScriptToCopyToIntermediateDirectory(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since it's now doing more than just adding a script, how about calling it UseIntermediateDirectory instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, sounds good

this StringBuilder scriptBuilder,
string sourceDir,
ref string sourceDir,
string intermediateDir,
IEnumerable<string> excludeDirs)
{
Expand All @@ -33,7 +33,6 @@ public static StringBuilder AddScriptToCopyToIntermediateDirectory(
}

var excludeDirsSwitch = string.Join(" ", excludeDirs.Select(dir => $"--exclude \"{dir}\""));

scriptBuilder
.AppendLine()
.AppendFormatWithLine("cd \"{0}\"", sourceDir)
Expand All @@ -42,7 +41,8 @@ public static StringBuilder AddScriptToCopyToIntermediateDirectory(
"rsync --delete -rt {0} . \"{1}\"",
excludeDirsSwitch,
intermediateDir)
.AppendFormatWithLine("cd \"{0}\"", intermediateDir);
.AppendLine();
sourceDir = intermediateDir;
return scriptBuilder;
}

Expand Down Expand Up @@ -92,7 +92,8 @@ public static StringBuilder AddScriptToSetupSourceAndDestinationDirectories(
{
scriptBuilder
.AppendFormatWithLine("SOURCE_DIR=\"{0}\"", sourceDir)
.AppendLine("export SOURCE_DIR");
.AppendLine("export SOURCE_DIR")
.AppendLine();

if (hasUserSuppliedDestinationDir)
{
Expand Down Expand Up @@ -223,7 +224,8 @@ public static StringBuilder AddScriptToBuildProject(this StringBuilder scriptBui
.AppendLine("echo")
.AppendFormatWithLine("echo \"Building project '{0}'\"", projectFile)
// Use the default build configuration 'Debug' here.
.AppendFormatWithLine("dotnet build \"{0}\"", projectFile);
.AppendFormatWithLine("dotnet build \"{0}\"", projectFile)
.AppendLine();
return scriptBuilder;
}

Expand Down
12 changes: 9 additions & 3 deletions src/BuildScriptGenerator/ScriptBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ internal static class ScriptBuilderExtensions
{
public static StringBuilder AppendSourceDirectoryInfo(this StringBuilder stringBuilder, string sourceDir)
{
stringBuilder.AppendFormatWithLine("echo Source directory : {0}", sourceDir);
stringBuilder
.AppendFormatWithLine("echo Source directory : {0}", sourceDir)
.AppendLine();
return stringBuilder;
}

public static StringBuilder AppendDestinationDirectoryInfo(
this StringBuilder stringBuilder,
string destinationDir)
{
stringBuilder.AppendFormatWithLine("echo Destination directory : {0}", destinationDir);
stringBuilder
.AppendFormatWithLine("echo Destination directory : {0}", destinationDir)
.AppendLine();
return stringBuilder;
}

Expand All @@ -29,7 +33,9 @@ public static StringBuilder AppendBenvCommand(this StringBuilder stringBuilder,
var benvPath = Path.Combine("/", "usr", "local", "bin", "benv");
if (File.Exists(benvPath))
{
stringBuilder.AppendFormatWithLine("source {0} {1}", benvPath, benvArgs);
stringBuilder
.AppendFormatWithLine("source {0} {1}", benvPath, benvArgs)
.AppendLine();
}

return stringBuilder;
Expand Down