2015-02-06 95 views
1

我想将运行MSBuild的一些旧批处理文件转换为PowerShell脚本。研究的Invoke-MSBuild命令,下面的代码是什么我赶上了:Powershell MSBuild错误

Invoke-MsBuild -Path "C:\path\solution.sln" -MsBuildParameters "/target:Clean;Rebuild /property:Configuration=Release;Platform=""x64"" /fl /flp:verbosity=normal;logfile=C:\path\logfile.log" -KeepBuildLogOnSuccessfulBuilds 

查看日志文件,当我运行它开始建设有MSBuild的解决方案文件的脚本,但我不断收到此错误:

error MSB8020: The builds tools for v120 (Platform Toolset = 'v120') cannot be found. To build using the v120 build tools, either click the Project menu or right-click the solution, and then select "Update VC++ Projects...". Install v120 to build using the v120 build tools.

我很困惑,因为我有使用12.0平台的Visual Studio 2013。我尝试重新安装v120构建工具,但没有任何改变。

+0

您的旧批处理脚本仍然在同一台计算机上工作吗?批处理命令是什么样的? – sburgess123 2015-02-07 22:59:39

+0

@ sburgess123是旧批处理脚本仍然有效: msbuild.exe C:\ path \ solution.sln/t:Clean;重建/ p:配置=发布;平台= x64 – 2015-02-09 19:09:25

+0

@StewC你在哪里启动旧批处理文件来自?也就是说,你是从Visual Studio命令提示符启动它吗?运行之前你正在运行任何设置吗? – NextInLine 2015-02-12 05:04:13

回答

1

很可能您的PowerShell环境不包含适当的环境变量(特别是%PATH%或$ env:PowerShell中的路径)。幸运的是,它很容易确认是这种情况:

  • 打开的Visual Studio 2013命令提示符
  • 运行PowerShell的
  • 运行您Invoke-MsBuild命令

如果它运行使用这些步骤,然后您的解决方案是:

  1. 摆弄PowerShell环境找到你的配置文件(在PowerShell中运行$profile以查找路径)。例如,可以通过添加行来修改路径$env:Path = $env:Path + ';another_path;yet_another_path'

  2. 查找由Visual Studio 2013命令提示符调用的批处理文件 - 创建一个调用该批处理文件的批处理文件,然后调用powershell,以便您的powershell在powershell实际运行之前配置环境。

+0

我按照步骤操作,但得到了相同的错误 – 2015-02-09 19:09:02

+0

您是否尝试过运行x86和x64 PowerShell? – NextInLine 2015-02-09 20:56:21

+0

是的,我尝试了他们两个 – 2015-02-12 00:47:31