I am trying to use Cake
's built in MSBuild
functionality to only build a specific Target (ie 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 WithTarget
extension 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:
settings.WithTarget("Compile");
Is actually not doing anything. However, if you do this:
var settings = new MSBuildSettings()
{
Verbosity = Verbosity.Diagnostic,
ToolVersion = MSBuildToolVersion.VS2017,
Configuration = "Release",
PlatformTarget = PlatformTarget.MSIL
};
MSBuild("./src/Cake.sln", settings.WithTarget("Compile");
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:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.