2

我想构建一个 VS2008 项目(ASP.NET Web 应用程序),然后使用 Microsoft.Build.Engine 发布。

到目前为止,我已经成功地构建了这个项目。

但我无法将其发布到指定目录。

我的构建方法是:

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

我的发布方法是:

private void PublishProject()
{

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

}

有任何想法吗 ???

4

2 回答 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();

}
于 2012-08-23T19:13:03.020 回答
1

这些是我为发布我的项目而设置的属性。

    DeployOnBuild=true;
    DeployTarget=Package;
    _PackageTempDir=$(PackagePath)
于 2012-08-22T20:11:47.177 回答