我的安装可能有问题,我不太确定。 我花了大约两天时间寻找和尝试不同的解决方案。很明显,人们已经做到了,但他们的例子对我来说还不适合。
我最终想要运行一个外部PowerShell脚本,但我很乐意让它首先运行:
psTest.build:
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0" DefaultTargets="Test">
<Target Name="Test">
<Exec Command='powershell -Command "Write-Host "Hello, world!""' />
</Target>
</Project>
运行构建脚本:
PS D:\> msbuild .\psTest.build /Target:test
Microsoft (R) Build Engine version 12.0.30723.0
[Microsoft .NET Framework, version 4.0.30319.18444]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 10/16/2014 3:20:31 PM.
Project "D:\psTest.build" on node 1 (test target(s)).
Test:
powershell -Command "Write-Host "Hello, world!""
I n t e r n a l W i n d o w s P o w e r S h e l l e r r o r . L o a d i n g m a n a g e d W i n d o w s
P o w e r S h e l l f a i l e d w i t h e r r o r 8 0 0 7 0 0 0 2 .
D:\psTest.build(5,5): error MSB3073: The command "powershell -Command "Write-Host "Hello, world!"" exited with c
ode -65536.
Done Building Project "D:\psTest.build" (test target(s)) -- FAILED.
Build FAILED.
"D:\psTest.build" (test target) (1) ->
(Test target) ->
D:\psTest.build(5,5): error MSB3073: The command "powershell -Command "Write-Host "Hello, world!"" exited with
code -65536.
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:01.10
我也尝试过使用MSBuild扩展包,但我仍然得到同样的错误。 所以,感觉就像有一个主要的脱节,一旦它完全脱离,其他一切都应该适合。