简体   繁体   中英

How to make Nop-Commerce 4.20 plugin ready for distribution

I am working with the new plugin of Nopcommerce 4.20 . The plugin is almost completed but I need to make the plugin ready for distribution. But there are unnecessary folders created inside Nop.Web/Plugins/ .

I made the Nop.Web and Nop.Web.Framework to "copy local=false" which are under Projects and deleted the plugin and build it again. But still, I am getting the unnecessary folders with two characters.

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

All things are perfect if you are not installing any Nuget Packages then please make false

<CopyLocalLockFileAssemblies>False</CopyLocalLockFileAssemblies>

and another thing Add replace these lines

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

Try these changes can help you.

I also had a problem with unnecessary folders being created. This turned out to be caused by the .Net Core 3.0 SDK, which apparently builds plugins in a different way than the version 2.x SDK's did. To check for this, you can run dotnet --version from the command line from within your nopcommerce project folder. The version should not be higher than 2.x.

The fix was to just tell dotnet to use a specific SDK version for building the project. This was just a matter of adding a global.json file in my nopcommerce project folder containing these lines:

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

Running dotnet --version again now gives the output 2.2.402 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM