2

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 ???

2 Answers 2

4
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();

}
Sign up to request clarification or add additional context in comments.

Comments

1

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

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

3 Comments

not sure where to set these ... these are not properties of Engine class nor the properties of BuildPropertyGroup ... can you please explain in little detail how to do publish?
hi ... i think i got what you meant ... I'll be posting the complete working method below ... :)
Sorry for not seeing this earlier. I'm glad you figured it out. Cheers!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.