I am trying to use Cake's built in MSBuild functionality to only build a specific Target (i.e. Compile). Using the example at: https://cakebuild.net/api/Cake.Common.Tools.MSBuild/MSBuildAliases/C240F0FB
var settings = new MSBuildSettings()
{
Verbosity = Verbosity.Diagnostic,
ToolVersion = MSBuildToolVersion.VS2017,
Configuration = "Release",
PlatformTarget = PlatformTarget.MSIL
};
settings.WithTarget("Compile");
MSBuild("./src/Cake.sln", settings);
But it seems to build all targets, where as i would like to only build a specific target, as detailed in: https://msdn.microsoft.com/en-us/library/ms171486.aspx
As per the documentation here:
https://cakebuild.net/api/Cake.Common.Tools.MSBuild/MSBuildSettingsExtensions/01F8DC03
The
WithTargetextension method returns the same instance of the MSBuildSettings with the modifications, it doesn't interact with the current instance. As a result, where you have:Is actually not doing anything. However, if you do this:
It should work how you intend it.
To help with this sort of thing, you can run Cake in diagnostic mode, to see exactly what command is being sent to the command line for execution. You can find more about that in this related question:
How to enable diagnostic verbosity for Cake