dotnet core, .net6 , .net7 , .net8 ,引入dll , 引入配置文件, 文件夹全部复制,
解决方案:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<!-- 👇👇👇👇👇引入dll 👇👇👇👇👇👇-->
<ItemGroup>
<Reference Include="XXXxxx.Cells">
<HintPath>..\dlls\XXXxxx.Cells.dll</HintPath>
</Reference>
</ItemGroup>
<!-- 👇👇👇👇👇引入lic文件 👇👇👇👇👇👇-->
<ItemGroup>
<Content Include="..\dlls\XXXxxx.Cells.lic">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<!-- 👇👇👇👇👇 将some_folder下的文件全部复制到bin目录下 👇👇👇👇👇👇-->
<ItemGroup>
<Content Include="..\dll\some_folder\**">
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Link>some_folder\%(RecursiveDir)%(Filename)%(Extension)</Link>
</Content>
</ItemGroup>
</Project>
关键说明:
Include 属性指向许可证文件的路径(与 XXXxxx.Cells.dll 在同一目录)。
CopyToOutputDirectory 属性设置为 PreserveNewest 表示仅在许可证文件较新时复制,或使用 Always 强制每次构建时都复制。