private MsBuildResult Build(TestSiteDeployerOptions options) { var properties = new Dictionary <string, string> { { "Configuration", options.BuildConfiguration }, { "SolutionDir", options.SolutionDir }, { "_PackageTempDir", options.DeployDirectory } }; if (!string.IsNullOrWhiteSpace(options.TransformationConfiguration)) { properties.Add("ProjectConfigTransformFileName", "Web." + options.TransformationConfiguration + ".config"); } if (options.AdditionalBuildProperties != null) { foreach (var property in options.AdditionalBuildProperties) { properties.Add(property.Key, property.Value); } } using (TemporaryFile defaultLogFile = new TemporaryFile(), errorLogFile = new TemporaryFile()) { var path = options.MsBuildExePathResolver(options.MsBuildToolsVersion, options.Use64BitMsBuild); var additionalLoggers = options.AdditionalMsBuildFileLoggers != null && options.AdditionalMsBuildFileLoggers.Any() ? string.Join(" ", options.AdditionalMsBuildFileLoggers.Select((l, i) => l.GetLoggerString(i + 3))) : ""; var arguments = string.Format( @"""{0}"" ""/p:{1}"" ""/t:{2}"" ""/v:{3}"" /fl1 ""/flp1:{4}"" /fl2 ""/flp2:{5}"" {6}", options.ProjectFilePath, string.Join(";", properties.Select(kvp => kvp.Key + "=" + kvp.Value)), string.Join(";", options.BuildTargets), options.MsBuildVerbosity, string.Format("LogFile={0};Verbosity={1}", defaultLogFile.Path, options.MsBuildVerbosity), string.Format("LogFile={0};ErrorsOnly", errorLogFile.Path), additionalLoggers ) // Fix escaping, since \" would lead to errors (since it would escape the quotes). // This happens mostly with directory properties (e.g. SolutionDir) which should end with a \. .Replace(@"\""", @"\\"""); var process = Process.Start(new ProcessStartInfo(path, arguments) { CreateNoWindow = !options.ShowMsBuildWindow, UseShellExecute = false }); Trace.Assert(process != null, "process != null"); process.WaitForExit(); return(process.ExitCode == 0 ? MsBuildResult.Success(defaultLogFile.GetContents()) : MsBuildResult.Failure(defaultLogFile.GetContents(), errorLogFile.GetContents())); } }