【问题标题】:Psake - How to activate /m switch for MSBuild?Psake - 如何为 MSBuild 激活 /m 开关?
【发布时间】:2016-07-22 04:45:59
【问题描述】:

您好,我正在尝试使用 MSBuild 和 Psake 编译我的项目,但在将 /m 传递给 MSBuild 时遇到问题。这是我的代码:

Exec {
    MSBuild $solutionFile "/p:Configuration=$buildConfiguration;Platform=$buildPlatform;OutDir=$tempPath /m"
}

MSBuild 输出:

“C:\Users\mabre\Source\Psake\Psake.sln”(默认目标)(1)-> "C:\Users\mabre\Source\Psake\src\Psake.Library\Psake.Library.xproj" (默认目标) (5) -> C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): 错误:找不到路径的一部分 'C:\Users\mabre\Source\Psake.build\temp \m\src\Psake.Library\obj\Release\netstandard1.6'。 [C:\Users\mabre\Source\Psake\src\Psake.Library\Psake.Library.xproj]

0 Warning(s)
4 Error(s)

注意 /m 现在是输出路径的一部分

错误:2016 年 7 月 22 日上午 12:39:04:在 C:\Users\mabre.nuget\packages\psake\4.6.0\tools\psake.psm1:156 char:17 + throw ("Exec:" + $errorMessage) +
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [>] 异常:执行:错误 执行命令 MSBuild $solutionFile "/p:Configuration=$buildConfiguration;Platform=$buildPlatform;OutDir=$tempPath /m" . 构建退出代码:1

提前致谢

【问题讨论】:

  • 您是否尝试将/m 放在第一位而不是最后一位,这样它就不会受到 Psake 之后可能添加的内容的影响?

标签: powershell msbuild psake


【解决方案1】:

尝试一下,不要将所有参数放在一个字符串中。以下是我的 MSBuild 任务在 pSake 中的两个示例:

Task CleanProject -depends RestoreNuget {
    Exec {
        msbuild `
            "$VisualStudioSolutionFile" `
            /target:Clean `
            /property:Configuration=$Configuration `
            /verbosity:quiet
    }
}

还有……

Task BuildProject -depends DeleteBinAndObjFolders {
    Exec {
        msbuild `
            "$ProjectPath" `
            /target:Rebuild `
            /property:Configuration=$Configuration `
            /property:OutDir="$ProjectBuildArtifactsPath" `
            /property:UseWPP_CopyWebApplication=True `
            /property:PipelineDependsOnBuild=False `
            /property:WebProjectOutputDir="$WebBuildArtifactsPath" `
            /verbosity:quiet
    }
}

请注意,我将" 放在我认为可能包含空格的所有变量周围。

所以试试这样吧:

Exec {
    MSBuild "$solutionFile" /p:Configuration=$buildConfiguration;Platform=$buildPlatform;OutDir="$tempPath" /m
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-26
    • 2011-03-18
    • 2019-06-06
    • 1970-01-01
    • 2011-10-30
    相关资源
    最近更新 更多