MSBuild command line - add dll link

I am using a makefile to compile my C # project. In this makefile, I create the tools.dll library that calls csc.exe, OK.

Now I want to use this .dll in my project. For some reason, I have to use MSBuild.exe, which use the .csproj file. In the .csproj file, I added this section:

<Reference Include="TOOLS"> <HintPath>C:\Gen\Lib\TOOLS.dll</HintPath> </Reference> 

It works great!

But my question is: How to add the tools.dll link from the MSBuild command line?

I need to call MSBuild.exe in the makefile and provide it with the path to the tools.dll file

+4
source share
2 answers

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 create a project using tools.dll use this command line:

 msbuild.exe yourproject.csproj /p:Configuration=Release;Platform=AnyCPU /p:ToolsDllPath=C:\Gen\Tools\bin\Release\Tools.dll 
+7
source

You cannot, msbuild only works with project files that already contain all the necessary information.

If you want to start compilation yourself and have full control, use csc.exe directly, there you can use the /r:assembly switch.

+2
source

Source: https://habr.com/ru/post/1340625/


All Articles