简体   繁体   English

如何使用Microsoft.Build.Evaluation(MSBuild)在构建之前执行清理

[英]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.

相关问题 如何使用 microsoft.build.evaluation 以编程方式添加新的 dll 参考 - How to add new dll reference programmatically using microsoft.build.evaluation 为什么Microsoft.Build.Evaluation在64位PC上将$(ProgramFiles)评估为“ c:\\ program files”? - Why does Microsoft.Build.Evaluation evaluate $(ProgramFiles) as “c:\program files” on 64 bit PC? 如何在Microsoft.Build.Evaluation.Project对象中找到AdditionalIncludeDirectories? - How do I find the AdditionalIncludeDirectories in a Microsoft.Build.Evaluation.Project object? 使用MSBuild,如何从命令行构建MVC4解决方案(在此过程中应用Web.config转换)并输出到文件夹? - Using MSBuild, how do I build an MVC4 solution from the command line (applying Web.config transformations in the process) and output to a folder? 如何使用Hudson在MSBuild中指定密钥密码? - How do I specify a keys password with MSBuild for the purpose of using Hudson? MSBuild如何从网络位置复制文件以构建计算机? - MSBuild How do I copy files to build machine from network location? 如何从MSBuild指定规则集 - How do I specify a ruleset from MSBuild 使用Microsoft.Build,以编程方式生成项目失败 - Building Project Programmatically Fails Using Microsoft.Build 如何在OSX上安装MSBUILD? - How do I install MSBUILD on OSX? 如何使用DataGrid执行不区分区域性的排序? - How do I perform a culture-insensitive sort using the DataGrid?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM