Import VS Projects - AX 2012 - Critical error Invalid AOT path specified

I'm sure that if you tried to move Visual Studio project without the help of model file (aka importing from xpos) you are getting errors, most likely: Critical error. Invalid AOT path specified. and Serious error during import of Visual Studio Project and ImportError at Token: (null) LineNo: 0.


So, to get over this you will have to manually import the projects, but you need to have the projects as they are saved in source control or when editing them in Visual Studio (this means the VS folder stucture and files). Once you have this just use this:

static void ImportVSProjects(Args _args)
{
    str             pathForProjects = @"C:\AxRepositoryC#\2012R2\CUS\Visual Studio Projects\";
    str             vsFileName = '';
    System.Array    filesArray;
    int             filesNo;
    int             i;
    ;
   
    if (System.IO.Directory::Exists(pathForProjects))
    {
        filesArray = System.IO.Directory::GetFiles(pathForProjects, @"*.csproj", System.IO.SearchOption::AllDirectories);
        filesNo = filesArray.GetLength(0);
       
        for (i = 0; i < filesNo; i++)
        {
            vsFileName = CLRInterop::getAnyTypeForObject(filesArray.GetValue(i));
            info (vsFileName);
            SysTreeNodeVSProject::importProject(vsFileName);
        }       
       
        info ("C# projects import complete.");
       
        filesArray = System.IO.Directory::GetFiles(pathForProjects, @"*.dynamicsproj", System.IO.SearchOption::AllDirectories);        filesNo = filesArray.GetLength(0);
       
        for (i = 0; i < filesNo; i++)
        {
            vsFileName = CLRInterop::getAnyTypeForObject(filesArray.GetValue(i));
            info (vsFileName);
            SysTreeNodeVSProject::importProject(vsFileName);
        }       
       
        info ("Model projects import complete.");
    }
    else
    {
        info ("Folder does not exist.");
    }       
}

2 comments:

  1. We are getting this error frequently while moving visual studio project to stage. Please can you explain why it happens.

    ReplyDelete
  2. Haven't researched as to why we get the error, but I believe there are cases when some special characters (white spaces) in the definition of a VS project break the xpo import ... (?)

    ReplyDelete