如何以给定的Release配置以编程方式编译项目?

时间:2015-09-01 14:19:52

标签: .net vb.net build msbuild-4.0

我想使用.vbproj文件在VB.NET中构建一个项目。文件内部有两个构建配置,一个Debug,一个Release。

    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <DefineDebug>true</DefineDebug>
        <DefineTrace>true</DefineTrace>
        <OutputPath>bin\Debug\</OutputPath>
        <DocumentationFile>program.xml</DocumentationFile>
        <NoWarn>42353,42354,42355</NoWarn>
        <UseVSHostingProcess>false</UseVSHostingProcess>
        <Prefer32Bit>false</Prefer32Bit>
        <WarningsAsErrors>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</WarningsAsErrors>
     </PropertyGroup>
     <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
        <DebugType>pdbonly</DebugType>
        <DefineDebug>false</DefineDebug>
        <DefineTrace>true</DefineTrace>
        <Optimize>true</Optimize>
        <OutputPath>\\192.168.1.15\program\Release\</OutputPath>
        <DocumentationFile>program.xml</DocumentationFile>
        <NoWarn>42353,42354,42355</NoWarn>
        <UseVSHostingProcess>false</UseVSHostingProcess>
        <Prefer32Bit>false</Prefer32Bit>
        <WarningsAsErrors>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</WarningsAsErrors>
     </PropertyGroup>

我想使用发布配置的所有这些给定信息来重建项目,但我不知道如何。到目前为止,这是我的代码:

    Dim logger As ConsoleLogger = New ConsoleLogger()
    Dim loggers As New List(Of ILogger)()
    loggers.Add(logger)
    coll.RegisterLoggers(loggers)

    Dim params = New BuildParameters()
    params.Loggers = loggers
    params.DetailedSummary = True

    Dim instance As ProjectInstance = New ProjectInstance(vbprojFile)

    Dim request = New BuildRequestData(instance, New String() {"Build"})

    BuildManager.DefaultBuildManager.ResetCaches()
    Dim result As BuildResult = BuildManager.DefaultBuildManager.Build(params, request)

这将在相对于vbprojFile的位置构建项目的Debug版本。我希望它将版本版本构建到\\192.168.1.15\program\Release\

是否有像

这样的东西
Dim request = New BuildRequestData(instance.Configuration("Release"), New String() {"Build"})

我可以用来完成这个吗?

0 个答案:

没有答案