[英]How do I perform a Clean before Building using Microsoft.Build.Evaluation (MSBuild)
I am using the following code to build a project. 我使用以下代码来构建项目。 I want to perform a Clean first (or just force a ReBuild I suppose?) - but I can't find any documentation stating how I do this:
我想首先执行一个Clean(或者只是强制一个ReBuild我想?) - 但我找不到任何文档说明我是如何做到这一点的:
Private Shared _globalProp As Dictionary(Of String, String)
Private Shared _logger As BuildLogger
Dim thisProject As Project = Nothing
Dim buildSuceeded As Boolean
If _globalProp Is Nothing Then
_globalProp = New Dictionary(Of String, String)
_globalProp.Add("Configuration", "Release")
_globalProp.Add("Platform", "x86")
End If
_logger = New BuildLogger
thisProject = New Project(projectFilename, _globalProp, "14.0")
buildSuceeded = thisProject.Build(_logger)
Credit to @JerryM for pointing in the right direction. 感谢@JerryM指向正确的方向。
I couldn't seem to find an appropriate overload of the Build method that accepted the targets and a logger at the same time, so I am doing this in two steps for now, this seems to do what I want: 我似乎无法找到同时接受目标和记录器的Build方法的适当重载,所以我现在分两步执行此操作,这似乎做我想要的:
thisProject = New Project(projectFilename, _globalProp, "14.0")
Dim targets As String() = {"Clean"}
cleanSucceeded = thisProject.Build(targets)
buildSuceeded = thisProject.Build(_logger)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.