private string GetArguments(MsBuildArgs config) { var list = new List <string>(); if (config.Targets != null && config.Targets.Count > 0) { list.Add("/t:" + string.Join(";", config.Targets)); } if (config.NoLogo.HasValue && config.NoLogo.Value) { list.Add("/nologo"); } if (config.Verbosity.HasValue) { switch (config.Verbosity.Value) { case MsBuildVerbosity.Quiet: list.Add("/v:q"); break; case MsBuildVerbosity.Minimal: list.Add("/v:m"); break; case MsBuildVerbosity.Normal: list.Add("/v:n"); break; case MsBuildVerbosity.Detailed: list.Add("/v:d"); break; case MsBuildVerbosity.Diagnostic: list.Add("/v:diag"); break; } } foreach (var property in config.Properties ?? Enumerable.Empty <KeyValuePair <string, string> >()) { list.Add("/p:{0}=\"{1}\"".F(property.Key, property.Value)); } if (config.ToolsVersion != null) { list.Add("/tv:" + config.ToolsVersion); } return(string.Join(" ", list)); }
public void Build(IEnumerable <BuildItem> projects, Action <MsBuildArgs> config) { if (projects == null) { throw new ArgumentNullException("projects"); } var args = new MsBuildArgs(); if (config != null) { config(args); } projects.Each(p => BuildProject(p, args)); }
private void BuildProject(BuildItem project, MsBuildArgs args) { using (_tracer.StartTask("MsBuild")) { _tracer.Info("Building '{0}'.", project); var exitCode = _process.Exec(p => { p.StartInfo.FileName = GetExecutable(args.ToolPath); p.StartInfo.Arguments = GetArguments(args) + " \"{0}\"".F(project); }); if (exitCode != 0) { throw new BuildCsException("MsBuild failed with exit code '{0}'.".F(exitCode)); } } }