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

D365FO – AX – Update Data Entity Target Entity fields with X++

How to Create Auto Lookup Using EDT with Table Reference in D365 F&O