powershell - 通过 Powershell 运行时 MSBuild 失败

标签 powershell msbuild

我有一个 MSBuild 脚本,我想在部署过程中从 PowerShell 脚本调用该脚本。如果我通过 bat 文件调用构建脚本,一切都会正常。如果我在 PowerShell 中执行完全相同的操作,我会收到 CS1668 错误,寻找我的计算机上不存在的奇怪且美妙的路径。 我知道我正在进入 MSBuild 脚本,因为这些错误是从 MSBuild 脚本目标内发生的(日志输出显示了这一点)。 bat 文件和 PowerShell 脚本位于同一位置,就在构建脚本旁边。

错误:

error CS1668 : Warning as error : Invalid search path 'C:\Program Files\Microsoft Visual Studio 8\VC\AtlMfc\Lib' specified in 'LIB environment variable' -- 'The system cannot find the path specified. ' error CS1668 : Warning as error : Invalid search path 'C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Lib' specified in 'LIB environment variable'-- 'The system cannot find the path specified. '

我已经检查过,我的机器上不存在这些路径。 为什么从 PowerShell 运行会改变 MSBuild 寻找的路径?

提前致谢

里斯C

编辑-添加代码:注意 MSBuild 脚本的名称是 AutomatedDebug.build POWERSHELL 脚本:

#Begining of script
$CurrentPath = Split-Path (Split-Path $myinvocation.mycommand.path )
#Assign the Build script paths. 1 is for building and testsing, 1 is for deployment (to keep things clean)
$MSBuildScriptBuildAndTestPath = $CurrentPath + "\Tools\AutomatedDebug.build"
$MSBuildScriptDeployPath = $CurrentPath + "\Tools\Deploy.build"

#Run the automated build with tests
Write-Host "*** Run the automated build with tests ***" 
C:\Windows\Microsoft.NET\Framework\v3.5\MSbuild.exe $MSBuildScriptBuildAndTestPath "/t:AllTests" "/l:FileLogger,Microsoft.Build.Engine;logfile=AllTests.log"
if($LastExitCode -ne 0)
{
    throw "AllTests failed"
}
Write-Host "*** FINISHED: Run the automated build with tests ***" 

bat 文件

@C:\Windows\Microsoft.NET\Framework\v3.5\MSbuild.exe AutomatedDebug.build /t:AllTests /l:FileLogger,Microsoft.Build.Engine;logfile="AllTests.log"
@pause
enter code here

最佳答案

好吧,实际发生的情况是,我在很多个月前下载了 Powershell 社区扩展 ( http://pscx.codeplex.com ),其中有一个 Environment.VisualStudio2005.ps1 文件添加了不存在的 EnvVars。这是(我假设)因为我不使用 VS2005。我已经评论了这一点,一切都很好。我试图寻找 2008 年的等效版本,但运气太差。老实说,我并没有充分发挥 powershell 的潜力,所以我怀疑我的机器上是否还需要 PSCX。

谢谢大家的帮助。

关于powershell - 通过 Powershell 运行时 MSBuild 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1005069/

相关文章:

powershell - 如何打开;另存为;然后从 PowerShell4 关闭 Excel 2013(启用宏)工作簿

node.js - Cordova 平台添加 wp7 失败 - msbuild 错误

msbuild - 使用xcopy将文件从多个目录复制到一个目录

visual-studio-2013 - 用于构建服务器的 Typescript 1.4 SDK?

c# - MSBuild 将动态生成的文件复制为项目依赖项的一部分

python - Graph API 以编程方式验证用户身份

azure - Microsoft Teams 访问策略(即 New-CsApplicationAccessPolicy 命令)存在问题

c# - Microsoft.NET.Sdk 和 Microsoft.NET.Sdk.Web 有什么区别

powershell - 为什么详细重定向会在导出的 CSV 文件中的数据之间创建一行?

powershell - 设置 TFS 构建版本号 PowerShell