问题描述
我使用的是 VS 2019 和 nopcommerce 4.40.4(.net 5)
我应该在我的插件中使用 nuget 包,
如果我将 copyLocalLockFileAssemblies 设置为 true,当我构建我的项目时,它会创建运行时文件夹,大约 65 MB,
如果我将 copyLocalLockFileAssemblies 设置为 false,它不会创建运行时文件夹,但是,我应该使用的 nuget 包的 dll 不包含在构建文件夹中,
你能帮我解决这个问题吗?
注意:将copy local设置为no,当我更改项目中使用的nop.Services时没有任何区别>
这是我的 csproj,我的包是 > SmsIrRestful.NetCore :
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<OutputPath>..\..\Presentation\nop.Web\Plugins\AttributeStockSMS</OutputPath>
<OutDir>$(OutputPath)</OutDir>
<!--Set this parameter to true to get the dlls copied from the NuGet cache to the output of your project.
You need to set this parameter to true if your plugin has a nuget package
to ensure that the dlls copied from the NuGet cache to the output of your project-->
<copyLocalLockFileAssemblies>false</copyLocalLockFileAssemblies>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<ClearPluginAssemblies Include="$(MSBuildProjectDirectory)\..\..\Build\ClearPluginAssemblies.proj" />
</ItemGroup>
<ItemGroup>
<None Remove="plugin.json" />
</ItemGroup>
<ItemGroup>
<Content Include="plugin.json">
<copyToOutputDirectory>PreserveNewest</copyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<packagereference Include="SmsIrRestful.NetCore" Version="1.1.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Libraries\nop.Services\nop.Services.csproj">
<Private>false</Private>
</ProjectReference>
</ItemGroup>
<Target Name="nopTarget" AfterTargets="Build">
<!-- Delete unnecessary libraries from plugins path -->
<MSBuild Projects="@(ClearPluginAssemblies)" Properties="PluginPath=$(MSBuildProjectDirectory)\$(OutDir)" Targets="nopClear" />
</Target>
</Project>
解决方法
不要使用 NuGet 引用,而是包含该 NuGet 包的 dll 文件。例如,您将使用 TaxJar 库,然后按照以下步骤操作。