如何在我的.csproj文件中包含DLL?

Mar*_*s S 8 c# msbuild compilation csproj c#-4.0

好吧,问题是我没有安装Visual Studio而且我不想安装它,因此,我制作了一个批处理文件来编译我的.csproj文件和所有源文件.

问题是我不知道如何包含.dll文件.这是我的.csproj文件的当前代码:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <AssemblyName>Project</AssemblyName>
    <OutputPath>Bin\</OutputPath>
  </PropertyGroup>

  <ItemGroup>
        <!-- .cs files -->
    <Compile Include="program.cs" />
  </ItemGroup>

  <Target Name="Build">
    <MakeDir Directories="$(OutputPath)"      Condition="!Exists('$(OutputPath)')" />
    <Csc Sources="@(Compile)" OutputAssembly="$(OutputPath)$(AssemblyName).exe" />
  </Target>
</Project>
Run Code Online (Sandbox Code Playgroud)

我需要更改什么才能将dll文件包含/引用到编译过程中?

Ste*_*eve 13

您将需要一个ItemGroup,其中包含名为Reference的项,如下所示:

<ItemGroup>
    <Reference Include="Microsoft.Practices.Unity" />
    <Reference Include="MvcMiniProfiler">
      <HintPath>..\packages\MiniProfiler.1.6\lib\MvcMiniProfiler.dll</HintPath>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.configuration" />
    <Reference Include="System.Core" />
    <Reference Include="System.Data.Entity" />
    <Reference Include="System.Runtime.Serialization" />
    <Reference Include="System.Security" />
    <Reference Include="System.Web" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Xml" />
  </ItemGroup>
Run Code Online (Sandbox Code Playgroud)

如果您要引用非GAC'd dll文件,你需要要么把在HintPath(见MVC迷你探查,这应该是相对于你的build文件的位置),或者你需要的路径传递到MSBuild的,在它的ReferencePath财产.