delegateas / XrmMockup

Engine which simulates your exact Dynamics 365/CRM instance locally including all of it's logic!
Other
70 stars 28 forks source link

New project structure does not support metadata from D365 instance. #233

Open thygesteffensen opened 4 months ago

thygesteffensen commented 4 months ago

Describe the bug MetadataGenerator365.exe and MetadataGenerator365.exe.config is not added to the Metadata folder when using the "new" project file structure.

To Reproduce Steps to reproduce the behavior:

  1. Create a new empty solution.
  2. Create new test project using the "new" project file structure.

Not Metadata folder is generated.

Expected behavior Metadata folder is generated with MetadataGenerator365.exe and MetadataGenerator365.exe.config.

Screenshots

Environment

Additional context This is not using the XrmFramework project structure due to using XrmToolkit ofr plugin registration and "metadata" generating.

When moving the MetadataGenerator365.exe and MetadataGenerator365.exe.config to the manually created Metadata folder, the tool throws this exception:

.\MetadataGenerator365.exe

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Invalid pointer (Exception from HRESULT: 0x80004003 (E_POINTER)) ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at DG.Tools.XrmMockup.Metadata.AssemblyGetter.GetAssemblyFromName(String Name)
   at DG.Tools.XrmMockup.Metadata.Program.ResolveXrmAssemblies(Object sender, ResolveEventArgs args)
   at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
   --- End of inner exception stack trace ---
   at DG.Tools.XrmMockup.Metadata.Program.GenerateMetadata()
   at DG.Tools.XrmMockup.Metadata.Program.Main(String[] args)

This is resolved by copying the Microsoft.* assemblies from bin/Release/net462 to the Metadata folder. It might be related, it might not or it might be me doing something wrong :|

thygesteffensen commented 4 months ago

And I did add this "hack":

    <!-- This ItemGroup is only here because the assembly getter in XrmMockup is stupid -->
    <ItemGroup>
        <Reference Include="Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
            <HintPath>bin\Release\net462\Microsoft.Xrm.Sdk.dll</HintPath>
        </Reference>
        <Reference Include="Microsoft.Xrm.Tooling.Connector, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
            <HintPath>bin\Release\net462\Microsoft.Xrm.Tooling.Connector.dll</HintPath>
        </Reference>
        <Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.19.8.16603, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
            <HintPath>bin\Release\net462\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
        </Reference>
        <Reference Include="Microsoft.Crm.Sdk.Proxy, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
            <HintPath>bin\Release\net462\Microsoft.Crm.Sdk.Proxy.dll</HintPath>
        </Reference>
    </ItemGroup>