NopCommerce:如何通过更新自定义插件的项目构建输出路径来生成 DLL 文件

NopCommerce: How to generate DLL file by updating the project build output path of custom plugin

我想为 nopcommerce 制作一个测试插件,正如 documentation 所说,我必须在 /plugins 目录和名称中创建一个文件夹应该是这样的:

Nop.Plugin.Widgets.Test

现在我需要更新项目构建输出路径。但是我不知道应该在哪里做!

因此,如果您知道我该怎么做并正确生成 DLL,请告诉我,我将不胜感激(我的职业生涯取决于此)

提前致谢。

您应该更新刚刚创建的项目的.csproj 文件中的输出路径。 我附上了一张图片作为在 visual studio 中点击的位置。该示例与您的情况相同,唯一不同的是所需插件的名称是 'Payments.CheckMoneyOrder' 而不是 'Widgets.Test'.

接下来,编辑输出路径,如下面 xml 所示。在您的情况下,这意味着将 'Payments.CheckMoneyOrder' 替换为 'Wigets.Test'。 Link to image

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

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <Copyright>Copyright © Nop Solutions, Ltd</Copyright>
    <Company>Nop Solutions, Ltd</Company>
    <Authors>Nop Solutions, Ltd</Authors>
    <PackageLicenseUrl></PackageLicenseUrl>
    <PackageProjectUrl>https://www.nopcommerce.com/</PackageProjectUrl>
    <RepositoryUrl>https://github.com/nopSolutions/nopCommerce</RepositoryUrl>
    <RepositoryType>Git</RepositoryType>
  <!--Edit your output path here! -->  
<OutputPath>..\..\Presentation\Nop.Web\Plugins\Payments.CheckMoneyOrder</OutputPath>
    <OutDir>$(OutputPath)</OutDir>
    <CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
  </PropertyGroup>

  <ItemGroup>
    <None Remove="logo.jpg" />
    <None Remove="plugin.json" />
    <None Remove="Views\Configure.cshtml" />
    <None Remove="Views\PaymentInfo.cshtml" />
    <None Remove="Views\_ViewImports.cshtml" />
  </ItemGroup>

  <ItemGroup>
    <Content Include="logo.jpg">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Include="plugin.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Include="Views\Configure.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Include="Views\PaymentInfo.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Include="Views\_ViewImports.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\..\Presentation\Nop.Web.Framework\Nop.Web.Framework.csproj" />
    <ClearPluginAssemblies Include="$(MSBuildProjectDirectory)\..\..\Build\ClearPluginAssemblies.proj" />
  </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>
```