14

好吧,问题是我没有安装 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>

我需要更改哪些内容才能将 dll 文件包含/引用到编译过程中?

4

1 回答 1

21

您将需要一个 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>

如果您引用非 GAC 的 dll,则需要放入 HintPath(请参阅 mvc mini profiler,这应该与您的构建文件位置相关),或者您需要在其 ReferencePath 中将路径传递给 MSBuild财产。

于 2011-10-19T14:42:59.393 回答