【问题标题】:NopCommerce: How to generate DLL file by updating the project build output path of custom pluginNopCommerce:如何通过更新自定义插件的项目构建输出路径来生成 DLL 文件
【发布时间】:2021-08-14 22:54:40
【问题描述】:

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

Nop.Plugin.Widgets.Test

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

所以,如果您知道我该如何做到这一点并正确生成 DLL,请告诉我,我将非常感激(我的职业生涯取决于此)

提前致谢。

【问题讨论】:

    标签: c# asp.net asp.net-core nopcommerce nopcommerce-4.2


    【解决方案1】:

    您应该更新刚刚创建的项目的 .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>
    ```
    

    【讨论】:

      猜你喜欢
      • 2019-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-29
      • 2021-06-13
      • 2014-10-17
      • 1970-01-01
      相关资源
      最近更新 更多