Beispiel #1
0
        private bool ExecuteBuild(BuildState state)
        {
            var req = new BuildRequestData(state.ProjectFile.FullName, globalBuildProperties, "4.0", new[] { "Clean", "Build" }, null);
            var parameters = new BuildParameters();
            var buildResult = BuildManager.DefaultBuildManager.Build(parameters, req);

            if (buildResult.OverallResult != BuildResultCode.Success)
            {
                if (buildResult.Exception != null)
                {
                    logger.ErrorException("Build failed for " + state.ProjectFile.FullName, buildResult.Exception);
                }
                else
                {
                    logger.Debug("Build failed for {0}", state.ProjectFile.FullName);
                }

                return false;
            }

            // This assumes that one and only one item is output from the build.
            state.OutputAssembly = new FileInfo(buildResult["Build"].Items.First().ItemSpec);
            return true;
        }