MSBuild how to pass parameter to set property value?

Suppose 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 to set the Externals property on the build server with a command that will call a custom CI.Build file which also will sit at the solution level. MSBuild is pretty new to me, I still looked for an answer to this question, but nothing I found did 100% for 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>

      

+3


source to share


1 answer


Run msBuild with the / p parameter to pass the argument:

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

      



MsBuild command line link

+4


source







All Articles