Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing MSBuild Arguments to Cake Build Script to produce _PublishedWebsites

I am currentlly in the process of writing a Cake build script to build a number of ASP.NET MVC sites.

At the moment I am unable to see an option to pass arguments to MSBuild to produce the _PublishedWebsites folder for deployment.

I believe the arguments that I need to pass are:

/p:OutDir=$(build.stagingDirectory)
/p:DeployOnBuild=true
/p:WebPublishMethod=Package
/p:PackageAsSingleFile=true 
/p:SkipInvalidConfigurations=true 

If there is an alternative approach which produces the same output content just not in the same folder directory that would be fine.

like image 274
SouthernDev Avatar asked Apr 20 '16 13:04

SouthernDev


2 Answers

The following example should set the correct MSBuild properties when building your website solution from Cake.

MSBuild("./src/Website.sln", new MSBuildSettings()
  .WithProperty("OutDir", "$(build.stagingDirectory)")
  .WithProperty("DeployOnBuild", "true")
  .WithProperty("WebPublishMethod", "Package")
  .WithProperty("PackageAsSingleFile", "true")
  .WithProperty("SkipInvalidConfigurations", "true"));

To set the output directory of the website, simply swap out the "$(build.stagingDirectory)" part with the path to the directory where you want the output to appear.

You can read more about the MSBuild alias in Cake here: http://cakebuild.net/api/cake.common.tools.msbuild/

like image 130
Patrik Svensson Avatar answered Nov 16 '22 09:11

Patrik Svensson


For FileSystem publish it can be done this way:

MSBuild(/**project path**/, settings =>
    settings.SetConfiguration(/**configuration**/)
    .WithProperty("DeployTarget", "WebPublish")
    .WithProperty("DeployOnBuild", /**boolean**/)
    .WithProperty("PackageAsSingleFile", /**boolean**/)
    .WithProperty("WebPublishMethod", "FileSystem")
    .WithProperty("PublishUrl", /**url**/)
);
like image 45
Thulani Chivandikwa Avatar answered Nov 16 '22 09:11

Thulani Chivandikwa