gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 18:20:40 25 4
gpt4 key购买 nike

嗯,问题是我没有安装 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 文件包含/引用到编译过程中?

最佳答案

您将需要一个 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,这应该与您的构建文件位置相关),或者您需要将路径传递给 MSBuild在其 ReferencePath 属性中。

关于c# - 如何在我的 .csproj 文件中包含 DLL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7822983/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com