I use a makefile to compile my C# project. In this makefile, I create a library tools.dll calling csc.exe, OK.
Now, I want to use this .dll in my project. For some reasons, I have to use MSBuild.exe which use .csproj file. In .csproj file I added this section :
<Reference Include="TOOLS">
<HintPath>C:\Gen\Lib\TOOLS.dll</HintPath>
</Reference>
That's works fine !
But my question is : How can I add tools.dll reference from MSBuild command line ?
I need that, to call MSBuild.exe in makefile and give it the path of tools.dll file
Actually you can.
<Project InitialTargets="ValidateToolsDllExists" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="ValidateToolsDllExists">
<Error
Text=" The ToolsDllPath property must be set on the command line."
Condition="'$(ToolsDllPath)' == ''" />
<Error
Text=" The ToolsDllPath property must be set to the full path to tools.dll."
Condition="!Exists('$(ToolsDllPath)')" />
</Target>
<PropertyGroup>
<!-- Default path to tools.dll -->
<ToolsDllPath Condition="'$(ToolsDllPath)'==''">C:\Gen\Lib\TOOLS.dll</ToolsDllPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="Tools">
<HintPath>$(ToolsDllPath)</HintPath>
</Reference>
</ItemGroup>
</Project>
to build your project with custom tools.dll use this command line:
msbuild.exe yourproject.csproj /p:Configuration=Release;Platform=AnyCPU /p:ToolsDllPath=C:\Gen\Tools\bin\Release\Tools.dll
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With