使用MSBuild 4.0,传递要从MSBuild任务在c#项目文件中扩展的属性名,如何? [英] Using MSBuild 4.0, passing property name to be expanded in c# project file from MSBuild task, how?
问题描述
我为CI流程创建了一个MSBuild脚本,在此脚本中,我使用MSBuild任务来编译解决方案:
I created a MSBuild script for our CI process and in this script I use a MSBuild task to compile the solution:
<PropertyGroup>
<MyOutPath>Output</MyOutPath>
</PropertyGroup>
<MSBuild
Projects="MySolution.sln"
Targets="Clean;Rebuild"
Properties="OutputPath=$(MyOutPath)\%24(AssemblyName)">
</MSBuild>
我希望c#项目文件使用输出路径,例如
I want the c# project files to use an output path like
- 项目MyAssemblyName1的
- Output \ MyAssemblyName1
- 项目MyAssemblyName2的Output \ MyAssemblyName2
AssemblyName属性来自C#项目文件,我希望在构建项目时在OutputPath属性中对其进行扩展.
The AssemblyName property is from the C# project file and I want it to be expanded in the OutputPath property when building the project.
现在,%24(AssemblyName)只是在文件系统上生成Output \ $(AssemblyName),这不是我想要的.
Right now, %24(AssemblyName) just produce Output\$(AssemblyName) on the filesystem which is not what I want.
毫不奇怪,使用$(AssemblyName)可以在父" MSBuild文件中扩展为空.
Not surprisingly, using $(AssemblyName) expands to nothing in the "parent" MSBuild file.
是否有什么方法可以稍后在目标项目文件中推迟AssemblyName属性的解析?
Is there any way to defer the resolution of the AssemblyName property later in the target project file?
此外,我不想修改.csproj文件,因为我希望从CI系统获得的影响最小.
Also, I do not want to modify the .csproj file as I want the least impact from the CI system.