Monday, December 11, 2017

How to import project from one model to another (D365FO)

Hello, Imagine a situation when you have a project that you developed in your own environment in some model. Then you need to import your project into another machine into a certain model (such design rules or something else that forces you to do this).
And then we do not know how to do it, because if we use the standard import method, then our project will load into the source model, and if it does not exist, then it will create it.

There are two ways to get out of this situation:
  • Download the project in a standard way, and then create a project in the model you want and duplicate all the elements from AOT that were in the imported project in your project. Well, then delete the elements and the project that you imported, Build, Sync and rename duplicate elements 
  • Move metadata items.
Imagine what we need to export project1 from "Model 1" to "Model2".
  • Export the project from one system. 
  • Import the project into another system. 
  • Go to the ...AOSService \ PackagesLocalDirectory \ "Model 1" \ folder and move the metadata of the items to the same directory for "Model 2". 
  • Go to the ...AOSService \ PackagesLocalDirectory \ "Model 1" \ XppMetadata \ "Model 1" \ folder and move the metadata of items to a similar directory for "Model 2".
Now you need to set up a new project. Open the VS and create a new project in "Model 2".
  • Go to the folder of the new project and find the .rnrproj file. The same file is found in the folder of the imported project. And then we set up our project, that is, we tied the moved elements to it. 
Example:


<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
    <Configuration>Debug</Configuration>
    <SchemaVersion>2.0</SchemaVersion>
    <Model>Model2</Model>
    <DBSyncInBuild>False</DBSyncInBuild>
    <GenerateFormAdaptors>False</GenerateFormAdaptors>
    <Company>
    </Company>
    <Partition>initial</Partition>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <OutputPath>bin</OutputPath>
    <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
    <DataEntityExpandParentChildRelations>False</DataEntityExpandParentChildRelations>
    <DataEntityUseLabelTextAsFieldName>False</DataEntityUseLabelTextAsFieldName>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
    <DebugSymbols>true</DebugSymbols>
    <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
  </PropertyGroup>
  <PropertyGroup>
    <ProjectGuid>{YourGUID}</ProjectGuid>
    <Name>ProjectForModel2</Name>
    <RootNamespace>ProjectForModel2</RootNamespace>
    <StartupObject>StartupClass</StartupObject>
    <StartupType>Class</StartupType>
  </PropertyGroup>
  <ItemGroup>
    <Folder Include="Classes\" />
    <Folder Include="Forms\" />
    <Folder Include="Service Groups\" />
    <Folder Include="Services\" />
    <Folder Include="Tables\" />
  </ItemGroup><ItemGroup>
    <Content Include="AxClass\StartupClass">
      <SubType>Content</SubType>
      <Name>StartupClass</Name>
      <Link>Classes\StartupClass</Link>
    </Content>
  </ItemGroup>
  <ItemGroup>
    <Reference Include="Newtonsoft, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
      <Name>Newtonsoft</Name>
      <HintPath>C:\Users\Administrator\Documents\Visual Studio 2015\Projects\Newtonsoft\Newtonsoft\bin\Debug\Newtonsoft.dll</HintPath>
    </Reference>
  </ItemGroup>
  <Import Project="$(MSBuildBinPath)\Microsoft.Common.targets" />
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Dynamics\AX\Microsoft.Dynamics.Framework.Tools.BuildTasks.targets" />
</Project>


Usually, in this file, most of the settings are given by the project, the only thing you need to change is to copy the block <ItemGroup><Folder>, <ItemGroup><Content> and <ItemGroup><Reference>. After that, you can delete the imported project.
  • Open your new project in VS. Build and Sync it.That's all. 
I would very appreciate some information about the logical explanation of how the metadata are placed in the file system in D365FO. Thanks

No comments:

Post a Comment