There are multiple ways to import a VS project.
One way you can do this is to create a class with the code from axfaq.blogspot.ro/.../code-import-ax-2012-importing-visual.html and use it to import the VS project; you can then call this class manually. (calling this class from the start up command using the -AutoRun I believe it's obsolete by now and would be replaced by the second option below).
The second way to do that, would be from PowerShell. There are the build scripts released by Microsoft which help us on that topic. This approach is using the MsBuild.exe and it goes something like:
Function ImportVSProjects([string] $modelFolder, [string] $modelName, [string] $layerCode, [string] $layerName, [string] $publisher, [string] $configName)
{
if ($modelName -eq '')
{
return
}
$aolParm = ''
if ($layerCode -ne '')
{
$aolParm = '/p:axAolCode={0}' -f $layerCode
}
$projPath = Join-Path $SourcePath 'ImportVSProjects.proj'
$logFile = Join-Path (Join-Path $BinariesPath "\Logs") ('VSImport.{0}.log' -f $modelName)
$errlogFile = Join-Path (Join-Path $BinariesPath "\Logs") ('VSImportError.{0}.err' -f $modelName)
$wrnlogFile = Join-Path (Join-Path $BinariesPath "\Logs") ('VSImportWarning.{0}.wrn' -f $modelName)
$sourceVSPath = Join-Path $SourcePath $modelFolder
$arguments = '"{0}" /p:srcFolder="{1}" /p:axLayer={2} {3} /p:ModelName="{4}" /p:Configuration=Release /l:FileLogger,Microsoft.Build.Engine;logfile="{5}" /p:ModelPublisher="{6}" /flp1:errorsonly;logfile="{7}" /flp2:WarningsOnly;logfile="{8}" /p:AXConfig="{9}"' -f $projPath, $SourceVSPath, $layerName, $aolParm, $modelName, $logFile, $publisher, $errlogFile, $wrnlogFile, $configName
$msBuild = "'{0}\msbuild.exe'" -f $MSBuildPath
$axProcess = Start-Process "msbuild.exe" -WorkingDirectory $MSBuildPath -PassThru -WindowStyle minimized -ArgumentList $arguments -Verbose
if ($axProcess.WaitForExit($AXSmallImportTimeout) -eq $false)
{
Throw ('Error import failed')
}
$retError = $true
if ((Test-Path $logfile) -eq $true)
{
$fileContent = Get-Content $logFile -ErrorAction SilentlyContinue
$lineNum = 0
foreach ($line in $fileContent)
{
$err = $line.Contains('0 Error(s)')
if ($err -eq $true)
{
$retError = $false
}
}
}
if ((Test-Path $errlogFile) -eq $true)
{
$fileContent = Get-Content $errlogFile -ErrorAction SilentlyContinue
if ($errlogFile -eq $null -or $errlogFile.Trim() -eq '')
{
$retError = $false
}
}
if($retError -eq $true)
{
Throw ('Error in compilation')
}
}
and for this you will need the ImportVSProjects.proj file you can get at gallery.technet.microsoft.com/.../Build-and-deploy-for-b166c6e4