Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild how to pass a parameter to set a property value?

Assume I have 3 cs projects in a solution and I import this Common.props file in all 3 csproj files.

Here is my Common.props file that will sit at the solution level, each project in my solution will import this Common.props file, I am trying to figure out how I can set the Externals property on the build server via command line that would call a custom CI.Build file that would also sit at the solution level also. MSBuild is pretty new to me, I did all kinds of searching for an answer to this but nothing I found made 100% sense to me.

   <?xml version="1.0" encoding="utf-8"?>
    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
        <PropertyGroup>
           <Externals Condition="'$(Externals)'==''">..\..\..\Externals\</Externals>
           </PropertyGroup>
           <ItemGroup>
               <ThirdPartyLibs Include="$(OutputPath)\*.dll" />
           </ItemGroup>
           <Target Name="BeforeResolveReferences">
           <PropertyGroup>
               <AssemblySearchPaths>$(Externals);$(AssemblySearchPaths)</AssemblySearchPaths>
           </PropertyGroup>
           </Target>
               <Target Name="BeforeBuild">
               <Message Text="$(Externals)"></Message>
           </Target>
           <Target Name="AfterBuild">
               <Message Text="After Build______"></Message>
           </Target>
           <Target Name="CleanDlls" AfterTargets="Clean">
               <Delete Files="@(ThirdPartyLibs)"></Delete>
           </Target>
    </Project>
like image 874
OutOFTouch Avatar asked Dec 02 '14 23:12

OutOFTouch


1 Answers

Start msBuild with /p option to pass argument :

MSBuild.exe /p:Externals="c:\Temp"

MsBuild command line reference

like image 89
Troopers Avatar answered Oct 15 '22 02:10

Troopers