Skip to content

Commit

Permalink
Fix dotnet-releaser new command (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoofx committed Feb 27, 2022
1 parent 9000623 commit c7b05fa
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 35 deletions.
34 changes: 0 additions & 34 deletions src/dotnet-releaser/ReleaserApp.New.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,47 +18,13 @@ private async Task<bool> CreateConfigurationFile(string? destinationFilePath, st
return false;
}

var finalProjectFilePath = Path.Combine(Environment.CurrentDirectory, projectFile);
string? changeLogPath = null;
if (!File.Exists(finalProjectFilePath))
{
Warn($"The project file path `{finalProjectFilePath}` was not found.");
}
else
{
var file = new FileInfo(finalProjectFilePath);
var originalDir = file.Directory!;
var dir = originalDir;
var dirPath = "";
while (dir is not null)
{
changeLogPath = Path.Combine(dir.FullName, "changelog.md");
if (File.Exists(changeLogPath))
{
changeLogPath = $"{dirPath}{Path.GetFileName(changeLogPath)}";
break;
}

changeLogPath = null;
dir = dir.Parent;
dirPath += "../";
}
}

var configAsText = $@"# configuration file for dotnet-releaser
[msbuild]
project = ""{projectFile.Replace('\\', '/')}""
[github]
user = ""{user ?? "github_user_or_org_here"}""
repo = ""{repo ?? "github_repo_here"}""
";
if (changeLogPath is not null)
{
configAsText += $@"[changelog]
path = ""{changeLogPath.Replace('\\', '/')}""
";
}


// Normalize the output
configAsText = configAsText.Replace("\r\n", "\n").Replace("\n", Environment.NewLine);
Expand Down
2 changes: 1 addition & 1 deletion src/dotnet-releaser/ReleaserApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static async Task<int> Run(string[] args)
app.Command("new", newCommand =>
{
newCommand.Description = "Create a dotnet-releaser TOML configuration file for a specified project.";
var configurationFileArg = AddTomlConfigurationArgument(newCommand, false);
var configurationFileArg = AddTomlConfigurationArgument(newCommand, true);
var projectOption = newCommand.Option<string>("--project <project_file>", "A - relative - path to project file (csproj, vbproj, fsproj)", CommandOptionType.SingleValue).IsRequired();
var userOption = newCommand.Option<string>("--user <GitHub_user/org>", "The GitHub user/org where the packages will be published", CommandOptionType.SingleValue);
var repoOption = newCommand.Option<string>("--repo <GitHub_repo>", "The GitHub repo name where the packages will be published", CommandOptionType.SingleValue);
Expand Down

0 comments on commit c7b05fa

Please sign in to comment.