Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public bool Build()
- {
- Dictionary<string, string> globalProperty = new Dictionary<string, string>
- {
- { "Configuration", "Debug" },
- { "Platform", "Any CPU" },
- { "VisualStudioVersion", "14.0"}
- };
- string pathToLog = ConfigHelper.CheckConfig("ServiceBuildLogPath");
- ProjectCollection pc = new ProjectCollection();
- BuildParameters bp = new BuildParameters(pc)
- {
- Loggers = new List<Microsoft.Build.Framework.ILogger>() { new Microsoft.Build.BuildEngine.FileLogger() { Parameters = "logfile=" + pathToLog + @"MSBuild.log" } },
- DefaultToolsVersion = "14.0"
- };
- BuildResult buildResult = null;
- BuildRequestData buildRequest;
- foreach (Solution solution in _services)
- {
- try
- {
- if (File.Exists(solution.PathToSolution))
- {
- if (_nugetPackageRestore.Restore(solution.PathToSolution))
- {
- buildRequest = new BuildRequestData(solution.PathToSolution, globalProperty, "4.0", new string[] { "Build" }, null);
- buildResult = Microsoft.Build.Execution.BuildManager.DefaultBuildManager.Build(bp, buildRequest);
- if (buildResult.OverallResult != BuildResultCode.Success)
- {
- if (buildResult.Exception != null)
- {
- throw buildResult.Exception;
- }
- throw new Exception(string.Format("Unable to build solution {0}", solution.Name));
- }
- }
- }
- else
- {
- throw new FileNotFoundException(string.Format("Solution {0} is unavailable", solution.Name));
- }
- }
- catch
- {
- throw;
- }
- }
- return buildResult != null && buildResult.OverallResult == BuildResultCode.Success;
- }
Add Comment
Please, Sign In to add comment