2011-10-19 39 views
5

Vâng, điều là tôi không có Visual Studio cài đặt và tôi không muốn cài đặt nó, vì vậy, tôi đã thực hiện một tập tin thực thi biên dịch tập tin .csproj của tôi và tất cả các tập tin nguồn của tôi quá.Làm cách nào để bao gồm các tệp DLL trong tệp .csproj của tôi?

Vấn đề là tôi không biết cách bao gồm các tệp .dll. Đây là mã hiện tại của tôi cho tệp .csproj của tôi:

<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> 

Tôi cần thay đổi gì để bao gồm/tham chiếu tệp dll vào quá trình biên dịch?

Trả lời

8

Bạn sẽ cần một ItemGroup với các mặt hàng được gọi là tham khảo như sau:

<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> 

Nếu bạn đang tham chiếu phi GAC'd dlls bạn sẽ cần phải hoặc đưa vào HintPath (xem profiler nhỏ MVC, điều này cần có liên quan đến vị trí tệp xây dựng của bạn), hoặc bạn sẽ cần phải chuyển đường dẫn đến MSBuild trong thuộc tính ReferencePath của nó.

Các vấn đề liên quan