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>
I want the c# project files to use an output path like
- Output\MyAssemblyName1 for the project MyAssemblyName1
- Output\MyAssemblyName2 for the project MyAssemblyName2
The AssemblyName property is from the C# project file and I want it to be expanded in the OutputPath property when building the project.
Right now, %24(AssemblyName) just produce Output\$(AssemblyName) on the filesystem which is not what I want.
Not surprisingly, using $(AssemblyName) expands to nothing in the “parent” MSBuild file.
Is there any way to defer the resolution of the AssemblyName property later in the target project file?
Also, I do not want to modify the .csproj file as I want the least impact from the CI system.
You could import the
.csprojproject file directly into your MSBuild script using the Import element. This way you could reference theAssemblyNameproperty directly:If you need to import the contents of a
.slnsolution file, first you’ll have to convert it to an MSBuild project file by setting theMSBuildEmitSolutionenvironment variable to1and run MSBuild on the solution file. This will generate aMySolution.sln.projfile, which you can then import into your script like described before: