web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

AX 2012 - Startup cmd to import C sharp projects

(0) ShareShare
ReportReport
Posted on by 1,920

Hi guys,

Could you please tell how to import the Visual Studio, C Sharp Projects using Startup command concept in AX 2012 R3 CU8.

I have done import the label files using aldimport likewise any command for C Sharp Projects.

Please help me on this, Thanks.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Iulian Cordobin Profile Picture
    8,201 on at

    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

  • Mohamed Meeran Profile Picture
    1,920 on at

    Thanks, It helped me to solve it.

  • Iulian Cordobin Profile Picture
    8,201 on at

    Please do not forget to Verify answer.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans