The*_*One 5 c# msbuild dll reference
我使用makefile来编译我的C#项目.在这个makefile中,我创建了一个库tools.dll,调用csc.exe,OK.
现在,我想在我的项目中使用这个.dll.出于某些原因,我必须使用使用.csproj文件的MSBuild.exe.在.csproj文件中我添加了这一部分:
<Reference Include="TOOLS">
<HintPath>C:\Gen\Lib\TOOLS.dll</HintPath>
</Reference>
Run Code Online (Sandbox Code Playgroud)
这很好用!
但我的问题是:如何从MSBuild命令行添加tools.dll引用?
我需要它,在makefile中调用MSBuild.exe并为其提供tools.dll文件的路径
Ser*_*kov 10
其实你可以.
<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>
Run Code Online (Sandbox Code Playgroud)
使用自定义tools.dll构建项目使用此命令行:
msbuild.exe yourproject.csproj /p:Configuration=Release;Platform=AnyCPU /p:ToolsDllPath=C:\Gen\Tools\bin\Release\Tools.dll
Run Code Online (Sandbox Code Playgroud)