惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
Cloudbric
Cloudbric
云风的 BLOG
云风的 BLOG
A
About on SuperTechFans
The GitHub Blog
The GitHub Blog
IT之家
IT之家
F
Full Disclosure
B
Blog RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Hugging Face - Blog
Hugging Face - Blog
B
Blog
H
Help Net Security
The Cloudflare Blog
Recorded Future
Recorded Future
P
Proofpoint News Feed
P
Proofpoint News Feed
C
Cisco Blogs
T
Tailwind CSS Blog
P
Palo Alto Networks Blog
D
Docker
爱范儿
爱范儿
Know Your Adversary
Know Your Adversary
博客园 - 聂微东
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Y
Y Combinator Blog
雷峰网
雷峰网
AWS News Blog
AWS News Blog
D
DataBreaches.Net
博客园 - 司徒正美
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - Franky
C
Cybersecurity and Infrastructure Security Agency CISA
Blog — PlanetScale
Blog — PlanetScale
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Latest news
Latest news
Google DeepMind News
Google DeepMind News
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
C
CERT Recently Published Vulnerability Notes
阮一峰的网络日志
阮一峰的网络日志
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
CXSECURITY Database RSS Feed - CXSecurity.com
酷 壳 – CoolShell
酷 壳 – CoolShell
C
Cyber Attacks, Cyber Crime and Cyber Security
腾讯CDC
小众软件
小众软件
G
Google Developers Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Scott Helme
Scott Helme
O
OpenAI News

博客园 - 经霄

Microsoft ProClarity 6.3 releases to manufacturing VSS Object Model Google Service 使用反射动态创建类的实例 - 经霄 - 博客园 AS2005中的维度安全性简介【转】 学位英语通过,特此庆祝一下 VS2005常用插件 AMO编程 - 经霄 - 博客园 Analysis Management Object对象模型 华为前员工:揭密华为“薪酬真相”【转】 VS2005中读写配置文件(一) 微软笔试试题——11月13日,2005年 Structure of the Basic MDX Query(转) 使用ADOMD.NET建立与Analysis Services的连接 IT公司薪水调查 ADOMD.net概述 SQL与MDX语法的比较 AdventureWorks数据库的安装 多维联机数据分析模型和系统设计方法[转]
Windows Services中使用MSBuild实现Build Automation Management
经霄 · 2006-09-19 · via 博客园 - 经霄

Microsoft Build Engine MSBuild)是MicrosoftVisual Studio的新的生成平台。它使得开发人员能够在没有安装Visual Studio 的环境下进行编译。

Windows Service应用程序是一种需要长期运行的应用程序,它没有用户界面,并且也不会产生任何可视化的输出(任何用户消息都会被写入Windows事件日志或者其它自定义的日志中)。因此,它特别适合于服务器环境。在计算机启动时,Windows Service就会自动开始运行(需要设置服务类型为Automatic),它们不需要用户一定登录才行。

Build Automation Management是为了标准化企业的自动化编译过程。通过Windows ServiceMSBuild的结合实现企业的Automation BuildBuild Automation Management可以处理scheduled  Build,也可以处理unscheduled build

创建Windows Service

Windows ServiceAccount设置为User。其它账户可能无权使用Proces

Windows Service中添加Build Code

MSBuild.exe位于%SystemRoot%\Micorsoft .NET\Framework\V2.0.502727目录下。因此,获取该目录所谓的绝对路径。

   string systemRoot = Path.GetDirectoryName(Environment.SystemDirectory);

            string FrameworkPath = systemRoot + @"\Microsoft.NET\Framework";

            if (!Directory.Exists(FrameworkPath))

            {

                throw new DirectoryNotFoundException("The framework directory could not be located.");

            }

            string msBuildDir = FrameworkPath + @"\v2.0.50727";   

获得所需要编译的设置选项。例如,需要编译DebugRelease两个版本。并将这些选项存放在一个临时变量中。    

            string[] configs = new string[] { "Debug", "Release", };    

获得项目路径并调用MSBuild进行编译。

            string projectPath = @"e:\temp\test\test.sln";

            eventLog1.WriteEntry("Start Build");

            foreach (string str in configs)

            {

                Process process = new Process();

                process.StartInfo.FileName = msBuildDir + @"\msbuild.exe";

                process.StartInfo.Arguments = projectPath + @" /p:Configuration=" + str + "\"";

                Console.WriteLine(process.StartInfo.Arguments);

                process.Start();

            }       
完整代码如下:

  string systemRoot = Path.GetDirectoryName(Environment.SystemDirectory);
            
string FrameworkPath = systemRoot + @"\Microsoft.NET\Framework";
            
if (!Directory.Exists(FrameworkPath))
            
{
                
throw new DirectoryNotFoundException("The framework directory could not be located.");
            }

            
string msBuildDir = FrameworkPath + @"\v2.0.50727";         
            
string[] configs = new string[] "Debug""Release};        
            string projectPath = @"e:\temp\test\test.sln";
            eventLog1.WriteEntry(
"Start Build");
            
foreach (string str in configs)
            
{
                Process process 
= new Process();
                process.StartInfo.FileName 
= msBuildDir + @"\msbuild.exe";
                process.StartInfo.Arguments 
= projectPath + @" /p:Configuration=" + str + "\"";
                Console.WriteLine(process.StartInfo.Arguments);
                process.Start();
            }