Плагины NopCommerce, встроенные в пользовательский плагин - PullRequest
0 голосов
/ 21 марта 2020

Я использую Nopcommerce 4.2 и пытаюсь создать собственный плагин.

Во время выполнения я получаю сообщение об ошибке:

System.Exception: 'A plugin with 'DiscountRequirement.MustBeAssignedToCustomerRole' system name is already defined

Когда я go для Nop.Web / Plugins, Я вижу все подключенные модули, в том числе и мои. Когда я смотрю в свой пользовательский плагин, я вижу папку с именем «Плагины», в которой содержатся все остальные встроенные плагины.

Я посмотрел на свой csproj и сравнил его с nop-плагинами по умолчанию и не могу работать почему мой снова создает все плагины.

, чтобы понять, какая структура создается:

Nop.Web

  • Плагины /

    - DiscountRules.CustomerRoles

    - ExchangeRate.EcbExchange

    --... Другие плагины ...

    - My.Plugin /

    ---- App_Data

    ---- Области

    ---- Плагины /

    ----- DiscountRules.CustomerRoles

    ----- ExchangeRate.EcbExchange

    -----... Другие плагины ...

файл моего проекта

<Project Sdk="Microsoft.NET.Sdk.Razor">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
      <OutputPath>..\..\Presentation\Nop.Web\Plugins\Widgets.MostViewedProducts</OutputPath>
    <OutDir>$(OutputPath)</OutDir>
    <EnableDefaultContentItems>false</EnableDefaultContentItems>
    <CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
  </PropertyGroup>

  <ItemGroup>
    <Compile Remove="Domain\**" />
    <Content Remove="Domain\**" />
    <EmbeddedResource Remove="Domain\**" />
    <None Remove="Domain\**" />
  </ItemGroup>

  <ItemGroup>
    <None Remove="logo.jpg" />
    <None Remove="plugin.json" />
  </ItemGroup>

  <PropertyGroup>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  </PropertyGroup>

  <ItemGroup>
    <Content Include="logo.jpg">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Include="plugin.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

  <ItemGroup>
    <Content Update="Areas\Admin\Views\BuilderProductAttribute\Create.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProductAttribute\Edit.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProductAttribute\List.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProductAttribute\_CreateOrUpdate.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\Create.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\Edit.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\List.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\ProductAttributeCatalogCreatePopup.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\ProductAttributeMappingCreate.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\ProductAttributeMappingEdit.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdate.Attributes.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdate.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdate.Info.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdate.SEO.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdateProductAttributeMapping.Catalog.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdateProductAttributeMapping.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdateProductAttributeMapping.Info.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\ProductBuilder\Configure.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\_ViewImports.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Update="Views\BuilderProduct\AttributeMappingProduct.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Update="Views\BuilderProduct\Details.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Update="Views\BuilderProduct\ProductDetails.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Update="Views\BuilderProduct\_CatalogSelectors.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Update="Views\BuilderProduct\_ProductBox.ProductBuilder.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Update="Views\_ViewImports.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
  </ItemGroup>

  <ItemGroup>
    <Folder Include="Areas\Admin\Controllers\" />
    <Folder Include="Areas\Admin\Extensions\" />
    <Folder Include="Areas\Admin\Factories\" />
    <Folder Include="Areas\Admin\Infrastructure\" />
    <Folder Include="Areas\Admin\Models\" />
    <Folder Include="Areas\Admin\Views\" />
    <Folder Include="Controllers\" />
    <Folder Include="Extensions\" />
    <Folder Include="Factories\" />
    <Folder Include="Models\" />
  </ItemGroup>


  <ItemGroup>
    <ProjectReference Include="..\..\Presentation\Nop.Web.Framework\Nop.Web.Framework.csproj" />
    <ProjectReference Include="..\..\Presentation\Nop.Web\Nop.Web.csproj" />
    <ClearPluginAssemblies Include="$(MSBuildProjectDirectory)\..\..\Build\ClearPluginAssemblies.proj" />
  </ItemGroup>


  <ItemGroup>
    <None Update="Views\Shared\Components\Default.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="Views\_ViewImports.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>

  <!-- This target execute after "Build" target -->
  <Target Name="NopTarget" AfterTargets="Build">
    <!-- Delete unnecessary libraries from plugins path -->
    <MSBuild Projects="@(ClearPluginAssemblies)" Properties="PluginPath=$(MSBuildProjectDirectory)\$(OutDir)" Targets="NopClear" />
  </Target>
</Project>

РЕДАКТИРОВАТЬ

Плагин. json

    {
  "InstalledPluginNames": [
    "Widgets.GoogleAnalytics",
    "Widgets.NivoSlider",
    "ExternalAuth.Facebook",
    "Misc.Cards",
    "Payments.PayPalSmartPaymentButtons",
    "Payments.PayPalStandard",
    "Catalog.SkipToProduct"
  ],
  "PluginNamesToUninstall": [],
  "PluginNamesToDelete": [
    "DiscountRequirement.MustBeAssignedToCustomerRole",
    "CurrencyExchange.ECB",
    "Misc.SendinBlue",
    "Payments.CheckMoneyOrder",
    "Payments.Manual",
    "Payments.Qualpay",
    "Payments.Square",
    "Pickup.PickupInStore",
    "Shipping.FixedByWeightByTotal",
    "Shipping.UPS",
    "Tax.Avalara",
    "Tax.FixedOrByCountryStateZip"
  ],
  "PluginNamesToInstall": []
}
...