编译.net .net Core程序 代码,仅做备份
//创建一个ProcessStartInfo对象 使用系统shell 指定命令和参数 设置标准输出 //编译.net core项目
var psi = new ProcessStartInfo("dotnet", "build inputproject/Lord.Core.sln") { RedirectStandardOutput = true };
psi.WindowStyle = ProcessWindowStyle.Hidden;
StringBuilder buildlog = new StringBuilder();
//启动
var proc = Process.Start(psi);
if (proc == null)
{
Console.WriteLine("Can not exec.");
}
else
{
//开始读取
using (var sr = proc.StandardOutput)
{
while (!sr.EndOfStream)
{
Console.WriteLine(sr.ReadLine());
buildlog.Append(sr.ReadLine() + "\r\n");
}
if (!proc.HasExited)
{
proc.Kill();
}
}
if (proc.ExitCode == )
{
Console.WriteLine("编译通过");
}
else
{
Console.WriteLine("编译未通过");
Console.WriteLine(buildlog.ToString());
}
}
var allfiles = Directory.GetFiles("inputproject", "*.dll", new EnumerationOptions() { RecurseSubdirectories = true });
var filterfiles = new List<string>();
var files = new List<string>();
foreach (var item in allfiles)
{
if (!filterfiles.Contains(Path.GetFileName(item)))
{
files.Add(item);
filterfiles.Add(Path.GetFileName(item));
}
}
List<Type> lsttypes = new List<Type>();
foreach (var item in files)
{
Assembly assembly = Assembly.LoadFile(Path.GetFullPath(item));
try
{
var types = assembly.GetTypes();
foreach (var tp in types)
{
if (tp.BaseType == typeof(System.Enum))
{
Console.WriteLine("Enum:" + tp.Name);
}
else if (tp.IsPublic && !tp.IsInterface && !tp.IsAbstract)
{
lsttypes.Add(tp);
}
}
}
catch
{
continue;
}
}
foreach (var tp in lsttypes)
{
Console.WriteLine(string.Concat("class:" + tp.FullName));
foreach (var item in tp.GetProperties())
{
Console.Write(item.Name + "|" + item.PropertyType + " ");
}
Console.WriteLine();
Console.WriteLine();
}
Console.ReadKey();
编译.net core项目
var process = new ProcessStartInfo("C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/MSBuild/15.0/Bin/MSBuild.exe", " E:/workZZF/src/SKIAD/LORD.SKIAD.WEB.sln /m /p:Platform=\"Any CPU\";CleanFile=\"true\";WarningLevel=0 /t:rebuild") { RedirectStandardOutput = true };
var x = Process.Start(process);
if (x == null)
{
Console.WriteLine("null");
return;
}
//开始读取
using (var sr = x.StandardOutput)
{
while (!sr.EndOfStream)
{
Console.WriteLine(sr.ReadLine());
//buildlog.Append(sr.ReadLine() + "\r\n");
}
if (!x.HasExited)
{
x.Kill();
}
}
if (x.ExitCode == )
{
Console.WriteLine("编译通过");
}
else
{
Console.WriteLine("编译未通过");
// Console.WriteLine(buildlog.ToString());
}
var allfiles = Directory.GetFiles("E:\\workZZF\\src\\SKIAD", "*.dll", new EnumerationOptions() { RecurseSubdirectories = true });
var filterfiles = new List<string>();
var files = new List<string>();
foreach (var item in allfiles)
{
if (!filterfiles.Contains(Path.GetFileName(item)))
{
files.Add(item);
filterfiles.Add(Path.GetFileName(item));
}
}
List<Type> lsttypes = new List<Type>();
foreach (var item in files)
{
try
{
Assembly assembly = Assembly.LoadFile(Path.GetFullPath(item));
var types = assembly.GetTypes();
foreach (var tp in types)
{
if (tp.BaseType == typeof(System.Enum))
{
Console.WriteLine("Enum:" + tp.Name);
}
else if (tp.IsPublic && !tp.IsInterface && !tp.IsAbstract)
{
lsttypes.Add(tp);
}
}
}
catch
{
continue;
}
}
foreach (var tp in lsttypes)
{
Console.WriteLine(string.Concat("class:" + tp.FullName));
foreach (var item in tp.GetProperties())
{
try
{
Console.Write(item.Name + "|" + item.PropertyType + " ");
}
catch
{
continue;
}
}
Console.WriteLine();
}
/ Console.ReadKey();
编译.net 项目 需要配置MSbuild.exe的位置,全路径
编译.net .net Core程序 代码,仅做备份的更多相关文章
- 把Asp.net Core程序代码部署到Ubuntu(不含数据库)
今天记录一下第一次把.net core 程序发布到linux系统.linux用的是ubuntu Server 18.04版本.运行的IDE是vs 2019,发布出来是.net core 2.2版本. ...
- 将Windows系统编译的.NET Core程序发布到Ubuntu系统
在可移植方面.NET Core应用程序分为两种,Portable application(便捷,需要目标机器安装.NET Core Runtime)和Self-contained applicatio ...
- WinPipe后门程序代码示例(仅限技术交流)
具体怎么编译,生成执行程序,不懂得先学习C++程序代码编译和集成开发环境. 多的不说了,只有两个代码文件,一个头文件,一个源文件.不多说了,直接上干货. (恶意使用,或者商用,后果自负,与本人无关.) ...
- 反编译工具 使用.NET JustDecompile来反编译你的程序代码
原文地址:http://www.it165.net/pro/html/201310/7383.html 前言 在项目的进行中有时会碰到需要去了解由第三方所开发的程序代码或者因为年久已经遗失原始码的程序 ...
- 使用.NET JustDecompile来反编译你的程序代码
前言 在项目的进行中有时会碰到需要去了解由第三方所开发的程序代码或者因为年久已经遗失原始码的程序,由于因为是别人写的所以我们并没有原始码可以直接阅读,碰到这种情况我们就需要去反编译这些程序及 DLL ...
- 编译调试 .NET Core 5.0 Preview 并分析 Span 的实现原理
很久没有写过 .NET Core 相关的文章了,目前关店在家休息所以有些时间写一篇新的
- BPF CO-RE 示例代码解析
BPF CO-RE 示例代码解析 在BPF的可移植性和CO-RE一文的末尾提到了一个名为runqslower的工具,该工具用于展示在CPU run队列中停留的时间大于某一值的任务.现在以该工具来展示如 ...
- 手把手教你用Jenkins自动发布dotnet core程序
Jenkins部分 首先,我们要有个Jenkins咯,下载链接:https://jenkins.io/download/ 我们安装官网教程安装好jenkins,安装教程略.... 嗯?不是说好手把手么 ...
- 从头认识一下docker-附带asp.net core程序的docker化部署
从头认识一下docker-附带asp.net core程序的docker化部署 简介 在计算机技术日新月异的今天, Docker 在国内发展的如火如荼,特别是在一线互联网公司, Docker 的使用是 ...
随机推荐
- Centos 6 安装python2.7.6
centos 是自带python的.但是版本稍微旧一些.搞python开发,肯定要用新一点的稳定版.所以,要升级一下python. 先去python主站下载python的源码包:Python-2.7. ...
- 洛谷 P2319 [HNOI2006]超级英雄
题目描述 题目描述 现在电视台有一种节目叫做超级英雄,大概的流程就是每位选手到台上回答主持人的几个问题,然后根据回答问题的多少获得不同数目的奖品或奖金.主持人问题准备了若干道题目,只有当选手正确回答一 ...
- DAX:New and returning customers
The New and Returning Customers pattern dynamically calculates the number of customers with certain ...
- centos7 搭建双网卡bond1(主备模式)实例
前景须知: 在redhat6 中网卡叫bond,在redhat7及centos7中改名team,此处只记录centos7中双网卡主备搭建过程. 应用情景:实现网络的高可用,防止一条网线或交换机故障影响 ...
- C++ 给自己的扫盲笔记
1.运算符new分配内存的格式: 指针变量名 = new 类型: 如分配一个20字节的name变量 :name = new char[20]; 2.strlen(s);函数: 返回字符串s的长度 ...
- SDOI2011 拦截导弹
题目描述 题解: 对于第一问,我们求二维LIS即可; 对于第二问,我们可以记录向前最长长度,向前最长方案数,向后最长长度,向后最长方案数. 其实改改树状数组即可. 还有,方案数一定要开double. ...
- 如何使用MySQL一个表中的字段更新另一个表中字段
[本文出自:https://www.jb51.net/article/150323.htm] 这篇文章主要介绍了如何使用MySQL一个表中的字段更新另一个表中字段,需要的朋友可以参考下 1,修改1列 ...
- 树梅派 -- 通过/sys读写ADC芯片 pcf8591
通过wiringPi等library, 在user space 通过/dev/i2c来读写i2c设备的方案不在本文讨论了. 编译SENSORS_PCF8591 模块 在Default raspberr ...
- 表单中的ngModelController
测试表单中的ngController.直接看红字结论部分即可 <!DOCTYPE html> <html lang="en"> <head> & ...
- 生成 Let's Encrypt 免费https证书
1.打开 SSL For Free 官网:https://www.sslforfree.com/ 2.在输入框内输入你要申请证书的域名,输入完点击 Create Free SSL Certificat ...