Esempio n. 1
0
        protected override void Execute(CodeActivityContext context)
        {
            console = context.GetExtension <ActivityConsole>();
            if (console == null)
            {
                console = new ActivityConsole();
            }

            if (!string.IsNullOrEmpty(CommandLineArguments.Get(context)))
            {
                console.WriteLine("!!!Warning - This activity currently ignores 'CommandLineArguments' argument. !!!");
            }

            var project = new Project(Project.Get(context));
            StringOutputLogger logger = new StringOutputLogger();

            project.SetGlobalProperty("Configuration", Configuration.Get(context) ?? "");
            project.SetGlobalProperty("Platform", Platform.Get(context) ?? "");
            project.SetProperty("OutDir", OutDir.Get(context) ?? "");
            bool   buildResult = project.Build(Targets.Get(context).ToArray(), new ILogger[] { logger });
            string buildOutput = string.Format(
                "MSBUILD - {0}\nConfiguration : {1}\nPlatform : {2}\nOutput Directory : {3}\n{4}",
                project.FullPath,
                project.GetProperty("Configuration").EvaluatedValue,
                project.GetProperty("Platform").EvaluatedValue,
                project.GetProperty("OutDir").EvaluatedValue,
                logger.GetOutput());

            BuildOutput.Set(context, buildOutput);
            BuildSuccess.Set(context, buildResult);
            ProjectCollection.GlobalProjectCollection.UnloadProject(project);

            console.WriteLine(buildOutput);
        }