【问题标题】:How to make Nop-Commerce 4.20 plugin ready for distribution如何使 Nop-Commerce 4.20 插件准备好分发
【发布时间】:2020-01-10 18:13:48
【问题描述】:

我正在使用Nopcommerce 4.20 的新插件。插件几乎完成了,但我需要让插件准备好分发。但是在Nop.Web/Plugins/ 中创建了不必要的文件夹。

我将 Nop.WebNop.Web.Framework 设置为 "copy local=false",它们位于 Projects 下,并删除了插件并重新构建它。但是,我仍然得到了带有两个字符的不必要的文件夹。

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<Copyright>SOME_COPYRIGHT</Copyright>
<Company>YOUR_COMPANY</Company>
<Authors>SOME_AUTHORS</Authors>
<PackageLicenseUrl>PACKAGE_LICENSE_URL</PackageLicenseUrl>
<PackageProjectUrl>PACKAGE_PROJECT_URL</PackageProjectUrl>
<RepositoryUrl>REPOSITORY_URL</RepositoryUrl>
<RepositoryType>Git</RepositoryType>

 <OutputPath>..\..\Presentation\Nop.Web\Plugins\Discount.ProductMix
</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>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
<ItemGroup>
  <None Remove="logo.jpeg" />
  <None Remove="plugin.json" />
  <None Remove="Views\Configure.cshtml" />
  <None Remove="Views\DiscountProductAddPopup.cshtml" />
  <None Remove="Views\_ViewImports.cshtml" />
</ItemGroup>
<ItemGroup>
  <Content Include="logo.jpeg">
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </Content>
  <Content Include="plugin.json">
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  </Content>
  <Content Include="Views\DiscountProductAddPopup.cshtml">
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </Content>
  <Content Include="Views\Configure.cshtml">
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </Content>
  <Content Include="Views\_ViewImports.cshtml">
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  </Content>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Presentation\Nop.Web.Framework\Nop.Web.Framework.csproj">
  <Private>false</Private>
</ProjectReference>
<ProjectReference Include="..\..\Presentation\Nop.Web\Nop.Web.csproj">
  <Private>false</Private>
</ProjectReference>
</ItemGroup>

<ItemGroup>
  <Compile Update="Controllers\DiscountProductMixController.cs">
    <CopyToOutputDirectory>Never</CopyToOutputDirectory>
  </Compile>
  <Compile Update="Data\DiscountOfferMixMap.cs">
    <CopyToOutputDirectory>Never</CopyToOutputDirectory>
  </Compile>
  <Compile Update="Data\DiscountProductMixObjectContext.cs">
    <CopyToOutputDirectory>Never</CopyToOutputDirectory>
  </Compile>
  <Compile Update="DiscountProductMixConfiguration.cs">
    <CopyToOutputDirectory>Never</CopyToOutputDirectory>
  </Compile>
  <Compile Update="Domain\DiscountOffers.cs">
    <CopyToOutputDirectory>Never</CopyToOutputDirectory>
  </Compile>
  <Compile Update="Infrastructure\DependencyRegistrar.cs">
    <CopyToOutputDirectory>Never</CopyToOutputDirectory>
  </Compile>
  <Compile Update="Infrastructure\PluginDBStartup.cs">
    <CopyToOutputDirectory>Never</CopyToOutputDirectory>
  </Compile>
  <Compile Update="Models\ConfigurationModel.cs">
    <CopyToOutputDirectory>Never</CopyToOutputDirectory>
  </Compile>
</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>

【问题讨论】:

    标签: nopcommerce nopcommerce-4.0 nopcommerce-4.1


    【解决方案1】:

    如果你没有安装任何 Nuget 包,一切都是完美的,那么请假

    <CopyLocalLockFileAssemblies>False</CopyLocalLockFileAssemblies>
    

    还有一件事 添加替换这些行

    <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" />
    

    试试这些改变可以帮助你。

    【讨论】:

      【解决方案2】:

      我还遇到了创建不必要文件夹的问题。结果证明这是由 .Net Core 3.0 SDK 引起的,它显然以与 2.x 版 SDK 不同的方式构建插件。要检查这一点,您可以从 nopcommerce 项目文件夹中的命令行运行 dotnet --version。版本不得高于 2.x。

      解决方法是告诉 dotnet 使用特定的 SDK 版本来构建项目。这只是在我的 nopcommerce 项目文件夹中添加一个 global.json 文件,其中包含这些行:

      {
        "sdk": {
          "version": "2.2.402"
        }
      }
      

      现在再次运行 dotnet --version 会得到输出 2.2.402

      【讨论】:

        猜你喜欢
        • 2017-02-10
        • 1970-01-01
        • 1970-01-01
        • 2020-03-07
        • 2013-10-16
        • 1970-01-01
        • 1970-01-01
        • 2015-07-12
        • 1970-01-01
        相关资源
        最近更新 更多