我很好奇,是否可以在MSBuild的命令行属性分配上引用宏?在msbuild上引用宏(12.0)命令行属性分配
E.g:
msbuild.exe MySolution.sln /p:CustomBeforeMicrosoftCSharpTargets="$(SolutionDir)\custom.targets"
会变成这样也当指定为从Visual Studio连接到TFS从 “编辑生成定义” “MSBuildArguments”/ “队列新建设” 的工作?
E.g:
/p:CustomBeforeMicrosoftCSharpTargets="$(SolutionDir)\custom.targets"
因为它似乎并没有被导入这些目标对我来说。但是在构建工作区中,目标文件与解决方案一起绝对存在。
我不想指定绝对路径。不知道如何使用相对路径在这里工作,在Internet上找不到任何建议,并且调试它非常困难,因为它是使用工作流在构建代理上调用的。工作流日志记录绝对是报告它使用这些参数调用MSBuild,但是在详细日志记录输出中的任何地方我都可以看到它正在引用CustomBeforeMicrosoftCSharpTargets
目标,或者调用它。
编辑
我写了一个小测试,构建项目buildme.proj
进一步我的理解。
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SetMe>NotInTheSandbox</SetMe>
</PropertyGroup>
<PropertyGroup>
<SomeMacroValue>c:\Sandbox\BuildTest</SomeMacroValue>
</PropertyGroup>
<PropertyGroup>
<AlreadySet>$(SomeMacroValue)\InTheSandbox</AlreadySet>
</PropertyGroup>
<Target Name="Build">
<Message Text="I am building!" />
<Message Text="Some macro value: $(SomeMacroValue)" />
<Message Text="$(SetMe)" />
<Message Text="$(AlreadySet)" />
</Target>
</Project>
当我用命令执行:
msbuild buildme.proj /p:SetMe="$(SomeMacroValue)\StillNotInSandbox"
我得到以下输出:
Microsoft (R) Build Engine version 12.0.31101.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 10/12/2015 22:12:08.
Project "C:\Sandbox\BuildTest\buildme.proj" on node 1 (default targets).
Build:
I am building!
Some macro value: c:\Sandbox\BuildTest
$(SomeMacroValue)\StillNotInSandbox
c:\Sandbox\BuildTest\InTheSandbox
Done Building Project "C:\Sandbox\BuildTest\buildme.proj" (default targets).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.02
所以很明显,它不表现我没有料到:宏观标识符出现在输出消息文本中。
有没有解决方案?
如何通过'/ P:MyCustomBeforeMicrosoftCSharpTargets = “custom.targets”'到项目,项目设置里面的属性CustomBeforeMicrosoftCSharpTargets为 “$(SolutionDir)\ $(MyCustomBeforeMicrosoftCSharpTargets)”? – stijn