How to clean in front of a building using Microsoft.Build.Evaluation (MSBuild)

I use the following code to create a project. I want to run Clean first (or just force ReBuild, I suppose?), But I can't find the documentation on how I do this:

    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)
+4
source share
1 answer

Credit @JerryM to point in the right direction.

I could not find a suitable overload of the Build method, which simultaneously accepted the goals and the registrar, so I do it in two stages, this seems to do what I want:

        thisProject = New Project(projectFilename, _globalProp, "14.0")

        Dim targets As String() = {"Clean"}
        cleanSucceeded = thisProject.Build(targets)

        buildSuceeded = thisProject.Build(_logger)
+1
source

Source: https://habr.com/ru/post/1623745/


All Articles