Knockout.js is not Loaded in D365FO MPOS/CPOS Extension Project Successfully / How to import Knockout.js in POS Extension.

 

Knockout.Js

How to Import Knockout.JS in POS Project.

If the Knockout.js is not loaded automatically ApplicationStartTrigger & BirthdayFieldsSection packageform AMER POS is not loaded successfully in POS



Solution:

Reference: https://learn.microsoft.com/en-us/dynamics365/commerce/dev-itpro/pos-extension/knockout-pos-extension

Refrence:https://github.com/microsoft/Dynamics365Commerce.InStore/blob/release/9.28/src/PosSample/Pos.Extension/Pos.Extension.csproj

Go to POS Project Right Click and unload it. See the project Source

Add KnockoutjsFile in PropertyGroup Element


<PropertyGroup>

    <TargetFramework>netstandard2.0</TargetFramework>

       <KnockoutjsFile>Libraries/knockout.js</KnockoutjsFile>

  </PropertyGroup>

 

 

Also add Target Element

<Target Name="ContentIncludeKnockoutLibrary" BeforeTargets="AssignTargetPaths" DependsOnTargets="RunResolvePackageDependencies">

             <PropertyGroup>

                    <KnockoutLibraryFilePath Condition="'%(PackageDefinitions.Name)' == 'knockoutjs'">%(PackageDefinitions.ResolvedPath)\Content\Scripts\knockout-%(PackageDefinitions.Version).js</KnockoutLibraryFilePath>

             </PropertyGroup>

             <Copy SourceFiles="$(KnockoutLibraryFilePath)" DestinationFiles="$(KnockoutjsFile)" SkipUnchangedFiles="true" />

             <!-- Necessary for CPOS -->

             <ItemGroup>

                    <Content Include="$(KnockoutjsFile)"></Content>

             </ItemGroup>

       </Target>




Final Result link This

<Project Sdk="Microsoft.NET.Sdk">
  <Import Project="..\CustomizationPackage.props" />

   <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <KnockoutjsFile>Libraries/knockout.js</KnockoutjsFile>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Dynamics.Commerce.Sdk.Pos" Version="$(CommerceSdkPackagesVersion)" />
    <PackageReference Include="Microsoft.TypeScript.MSBuild" Version="4.0.*" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\CommerceRuntime\CommerceRuntime.csproj" />
  </ItemGroup>

<Target Name="ContentIncludeKnockoutLibrary" BeforeTargets="AssignTargetPaths" DependsOnTargets="RunResolvePackageDependencies">
    <PropertyGroup>
        <KnockoutjsFile>Libraries/knockout.js</KnockoutjsFile>
        <KnockoutLibraryFilePath Condition="'%(PackageDefinitions.Name)' == 'knockoutjs'">%(PackageDefinitions.ResolvedPath)\Content\Scripts\knockout-%(PackageDefinitions.Version).js</KnockoutLibraryFilePath>
    </PropertyGroup>
    <Copy SourceFiles="$(KnockoutLibraryFilePath)" DestinationFiles="$(KnockoutjsFile)" SkipUnchangedFiles="true" /> <!-- Necessary for CPOS -->
    <ItemGroup>
        <Content Include="$(KnockoutjsFile)"></Content>
    </ItemGroup>
</Target>

</Project>




 

Comments

Popular posts from this blog

Update Deployment Failed due to Missing MpProvider Module

How to Resolve DVT Script Issues When Applying Quality Updates in LCS for D365FO

How to remove deployed model in Tier2 environment in D365FO