Build and Publish (ASP.NET Web Application) using Microsoft.Build.Engine using c#

I want to Build a VS2008 project (ASP.NET Web Application) and then publish using Microsoft.Build.Engine.

I have so far successfully managed to BUild the project.

But i am unable to Publish it to a specified directory.

My build method is:

private void BuildProject()
{
            Engine engine = new Engine();
            FileLogger logger = new FileLogger();
            logger.Parameters = @"logfile=C:\temp\build.log";
            engine.RegisterLogger(logger);

            BuildPropertyGroup bpg = new BuildPropertyGroup();
            bpg.SetProperty("Configuration", "Debug");
            bpg.SetProperty("Platform", "AnyCPU");

            bool success = engine.BuildProjectFile(GetProjectFileName(), null, bpg);

            if (success)
                Console.WriteLine("Success!");
            else
                Console.WriteLine("Build failed - look at c:\temp\build.log for details");

            engine.UnloadAllProjects();
            engine.UnregisterAllLoggers();
}

And my publish method is:

private void PublishProject()
{

           //no idea what goes here ... please help !!!

}

Any ideas ???

Answers


private void PublishProject()
{

Engine engine = new Engine();
            FileLogger logger = new FileLogger();
            logger.Parameters = @"logfile=C:\temp\publish.log";
            engine.RegisterLogger(logger);

            BuildPropertyGroup bpg = new BuildPropertyGroup();
            bpg.SetProperty("OutDir", @"C:\outdir\");
            bpg.SetProperty("Configuration", "Debug");
            bpg.SetProperty("Platform", "AnyCPU");
            bpg.SetProperty("DeployOnBuild", "true");
            bpg.SetProperty("DeployTarget", "Package");
            bpg.SetProperty("PackageLocation", @"$(OutDir)\MSDeploy\Package.zip");
            bpg.SetProperty("_PackageTempDir", @"C:\temp\");


            bool success = engine.BuildProjectFile(GetProjectFileName(), null, bpg);

            if (success)
                Console.WriteLine("Success!");
            else
                Console.WriteLine(@"Build failed - look at c:\temp\publish.log for details");

            engine.UnloadAllProjects();
            engine.UnregisterAllLoggers();

}

These are the properties I set to publish a project of mine.

    DeployOnBuild=true;
    DeployTarget=Package;
    _PackageTempDir=$(PackagePath)

Need Your Help

WPF The type or namespace name 'Browser' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)

c# .net wpf silverlight namespaces

I currently changing my application from Silverlight to WPF. I have this peice of code which is giving me an error in wpf.

Copy image from url using timthumb

php image resize copy timthumb

I'm currently working on an uploading, resizing & cropping script.