<Project>



	<Target Name="CopyNugetPackages" AfterTargets="Build">
		<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
			<!-- setting up the variable for convenience -->
			<ApplicationPackageFiles Include="$(PkgMQTTnet_AspNetCore)\lib\net6.0\*.*" />
			<MQTTnetApplicationPackageFiles Include="$(PkgMQTTnet)\lib\net6.0\*.*" />
		</ItemGroup>
		<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
			<!-- setting up the variable for convenience -->
			<ApplicationPackageFiles Include="$(PkgMQTTnet_AspNetCore)\lib\net8.0\*.*" />
			<MQTTnet_ServerApplicationPackageFiles Include="$(PkgMQTTnet_Server)\lib\net8.0\*.*" />
			<MQTTnetApplicationPackageFiles Include="$(PkgMQTTnet)\lib\net8.0\*.*" />
		</ItemGroup>
		<PropertyGroup>
			<ApplicationFolder>$(TargetDir)</ApplicationFolder>
		</PropertyGroup>
		<Copy SourceFiles="@(ApplicationPackageFiles)" DestinationFolder="$(ApplicationFolder)%(RecursiveDir)" />
		<Copy SourceFiles="@(MQTTnet_ServerApplicationPackageFiles)" DestinationFolder="$(ApplicationFolder)%(RecursiveDir)" />
		<Copy SourceFiles="@(MQTTnetApplicationPackageFiles)" DestinationFolder="$(ApplicationFolder)%(RecursiveDir)" />
	</Target>


	<!--在构建后触发的。它通过在 Nuget 包的 Content 文件夹中包含目标目录中的所有文件和子文件夹来创建 nuget 包-->
	<Target Name="IncludeAllFilesInTargetDir" AfterTargets="Build">
		<ItemGroup>
			<Content Include="$(ProjectDir)$(OutputPath)\$(TargetFramework)\**\*MQTT*.dll">
				<Pack>true</Pack>
				<PackagePath>Content</PackagePath>
			</Content>
		</ItemGroup>
	</Target>

</Project>
