nlog.config 改为内嵌;
添加生成后事件;
This commit is contained in:
+17
-2
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BarrageGrab.Modles.JsonEntity;
|
using BarrageGrab.Modles.JsonEntity;
|
||||||
@@ -11,9 +12,23 @@ namespace BarrageGrab
|
|||||||
{
|
{
|
||||||
public static class Logger
|
public static class Logger
|
||||||
{
|
{
|
||||||
private static NLog.Config.ISetupBuilder builder = LogManager.Setup().LoadConfigurationFromFile("nlog.config");
|
private static NLog.Config.ISetupBuilder builder;
|
||||||
|
|
||||||
private static readonly NLog.Logger logger = builder.GetLogger("*");
|
private static NLog.Logger logger;
|
||||||
|
|
||||||
|
static Logger()
|
||||||
|
{
|
||||||
|
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||||
|
//读取嵌入式资源文件
|
||||||
|
var resourceName = assembly.GetManifestResourceNames().FirstOrDefault(s => s.EndsWith("nlog.config"));
|
||||||
|
if (resourceName == null)
|
||||||
|
{
|
||||||
|
throw new Exception("nlog.config 嵌入式资源不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = LogManager.Setup().LoadConfigurationFromAssemblyResource(assembly, resourceName);
|
||||||
|
logger = builder.GetLogger("*");
|
||||||
|
}
|
||||||
|
|
||||||
public static void PrintColor(string message, ConsoleColor foreground = ConsoleColor.White)
|
public static void PrintColor(string message, ConsoleColor foreground = ConsoleColor.White)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -258,9 +258,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
<None Include="nlog.config">
|
<EmbeddedResource Include="nlog.config">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CustomToolNamespace>WssBarrageService</CustomToolNamespace>
|
||||||
</None>
|
</EmbeddedResource>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<None Include="Properties\app.manifest" />
|
<None Include="Properties\app.manifest" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -315,4 +315,12 @@
|
|||||||
</Target>
|
</Target>
|
||||||
<Import Project="..\packages\Costura.Fody.5.7.0\build\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.5.7.0\build\Costura.Fody.targets')" />
|
<Import Project="..\packages\Costura.Fody.5.7.0\build\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.5.7.0\build\Costura.Fody.targets')" />
|
||||||
<Import Project="..\packages\Fody.6.8.2\build\Fody.targets" Condition="Exists('..\packages\Fody.6.8.2\build\Fody.targets')" />
|
<Import Project="..\packages\Fody.6.8.2\build\Fody.targets" Condition="Exists('..\packages\Fody.6.8.2\build\Fody.targets')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<PostBuildEvent>if "$(ConfigurationName)" == "Release" (
|
||||||
|
del /q "$(TargetDir)*.xml"
|
||||||
|
del /q "$(TargetDir)*.pdb"
|
||||||
|
del /q "$(TargetDir)*.pfx"
|
||||||
|
rmdir /s /q "$(TargetDir)crts"
|
||||||
|
)</PostBuildEvent>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user