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

chore: fix ReferenceBuilder path handling for VS Debug and dotnet run #90

Merged
merged 1 commit into from
Feb 13, 2024
Merged
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
12 changes: 8 additions & 4 deletions sandbox/ReferenceBuilder/Program.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
using MarkdownGenerator;
using System.Reflection;

var f = Factory();
var o = Operator();

File.WriteAllText("../../../../../docs/reference_factory.md", f);
File.WriteAllText("../../../../../docs/reference_operator.md", o);
// Get absolute path of bin/Debug/TargetFramework/ReferenceBuilder.dll
// Location = /Foo/Bar/R3/sandbox/ReferenceBuilder/bin/Debug/net8.0/ReferenceBuilder.dll
var basePath = Assembly.GetAssembly(typeof(Program))!.Location;
File.WriteAllText(Path.Combine(basePath, "../../../../../../docs/reference_factory.md"), f);
File.WriteAllText(Path.Combine(basePath, "../../../../../../docs/reference_operator.md"), o);

// replace readme
var text = File.ReadAllLines("../../../../../ReadMe.md");
var text = File.ReadAllLines(Path.Combine(basePath, "../../../../../../ReadMe.md"));

(int head, int tail)? factoryLines = null;
(int head, int tail)? operatorLines = null;
Expand Down Expand Up @@ -84,7 +88,7 @@
}

var nt = string.Join(Environment.NewLine, newText);
File.WriteAllText("../../../../../ReadMe.md", nt);
File.WriteAllText(Path.Combine(basePath, "../../../../../../ReadMe.md"), nt);

static string Factory()
{
Expand Down