Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
统一行尾为 \R\N
  • Loading branch information
yuanwj
yuanwj committed Mar 3, 2022
commit a1005f4fbd9642359f6caec735b2e06684528279
6 changes: 5 additions & 1 deletion src/SmartCode.App/Outputs/FileOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using HandlebarsDotNet;
using SmartCode.Configuration;
using SmartCode.Utilities;
using System.Text.RegularExpressions;

namespace SmartCode.App.Outputs
{
Expand Down Expand Up @@ -83,9 +84,12 @@ public async Task Output(BuildContext context, Output output = null)
}
}

//采购VS默认的UTF-8 WITH BOM 编码
using (StreamWriter streamWriter = new StreamWriter(filePath, false, new UTF8Encoding(true)))
{
await streamWriter.WriteAsync(context.Result.Trim());
//强制行尾为 \r\n
var result = Regex.Replace(context.Result.Trim(), @"[\r\n]+", "\r\n", RegexOptions.Multiline);
await streamWriter.WriteAsync(result);
}

_logger.LogInformation($"------ Mode:{output.Mode},Build:{context.BuildKey} -> {filePath} End! ------");
Expand Down