diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..722d5e7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vscode diff --git a/Dockerfile.core b/Dockerfile.core new file mode 100644 index 0000000..97d6b0f --- /dev/null +++ b/Dockerfile.core @@ -0,0 +1,49 @@ +# escape=` +ARG BASE +FROM mcr.microsoft.com/windows/servercore:$BASE as mother +ARG NCHVERSION +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] + +RUN Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force; ` + Install-Module navcontainerhelper -MinimumVersion $env:NCHVERSION -MaximumVersion $env:NCHVERSION -Force; + +ARG TYPE +ARG COUNTRY +ARG VERSION + +RUN Import-Module navcontainerhelper; ` + Download-Artifacts -artifactUrl (Get-BCArtifactUrl -type $env:TYPE -country $env:COUNTRY -version $env:VERSION) -includePlatform; + +RUN New-Item -Path c:\artifacts -ItemType Directory; ` + New-Item -Path c:\bin -ItemType Directory; ` + Start-Process "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\Prerequisite` Components\Open` XML` SDK` 2.5` for` Microsoft` Office\OpenXMLSDKv25.msi" "/qn" -PassThru | Wait-Process; ` + Copy-Item "C:\Program` Files` `(x86`)\Open` XML` SDK\V2.5\lib" "C:\assemblies\OpenXMLSdk" -Recurse; ` + Copy-Item "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\ModernDev\program` files\Microsoft` Dynamics` NAV\*\AL` Development` Environment\ALLanguage.vsix" "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\ALLanguage.zip"; ` + Copy-Item "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\ModernDev\program` files\Microsoft` Dynamics` NAV\*\AL` Development` Environment\System.app" "C:\artifacts\System.app"; ` + Get-ChildItem -Path "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\$env:COUNTRY" -Filter *.app -Recurse | % { Copy-Item $_.FullName "C:/artifacts/" }; ` + Expand-Archive "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\ALLanguage.zip" "C:\alc"; ` + Copy-Item "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\LegacyDlls\program` files\Microsoft` Dynamics` NAV\160\RoleTailored` Client" "C:\assemblies\RoleTailoredClient" -Recurse; ` + Copy-Item "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\ServiceTier\program` files\Microsoft` Dynamics` NAV\160\Service" "C:\assemblies\Service" -Recurse; ` + Copy-Item "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\Test` Assemblies\Mock` Assemblies" "C:\assemblies\MockAssemblies" -Recurse; + +FROM mcr.microsoft.com/windows/servercore:$BASE +ARG TYPE +ARG COUNTRY +ARG VERSION +COPY --from=mother c:/alc/extension/bin c:/bin +COPY --from=mother C:/artifacts C:/symbols +COPY --from=mother C:/assemblies c:/assemblies +COPY Dummy.ruleset.json c:\dummy.ruleset.json + +ENV rulesetfile='c:\dummy.ruleset.json' +CMD c:\bin\win32\alc.exe ` + /project:c:\src ` + /packagecachepath:c:\symbols ` + /out:c:\src\app.app ` + /errorlog:c:\src\alc.log ` + /loglevel:Warning ` + /ruleset:%rulesetfile% ` + /analyzer:c:\bin\Analyzers\Microsoft.Dynamics.Nav.CodeCop.dll ` + /analyzer:c:\bin\Analyzers\Microsoft.Dynamics.Nav.AppSourceCop.dll ` + /analyzer:c:\bin\Analyzers\Microsoft.Dynamics.Nav.UICop.dll ` + /assemblyprobingpaths:"c:\assemblies\OpenXMLSdk","C:\src\.netpackages","C:\assemblies\RoleTailoredClient","C:\assemblies\Service","C:\assemblies\MockAssemblies","c:\windows\assembly" \ No newline at end of file diff --git a/Dockerfile.nano b/Dockerfile.nano new file mode 100644 index 0000000..abd0387 --- /dev/null +++ b/Dockerfile.nano @@ -0,0 +1,49 @@ +# escape=` +ARG BASE +FROM mcr.microsoft.com/windows/servercore:$BASE as mother +ARG NCHVERSION +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] + +RUN Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force; ` + Install-Module navcontainerhelper -MinimumVersion $env:NCHVERSION -MaximumVersion $env:NCHVERSION -Force; + +ARG TYPE +ARG COUNTRY +ARG VERSION + +RUN Import-Module navcontainerhelper; ` + Download-Artifacts -artifactUrl (Get-BCArtifactUrl -type $env:TYPE -country $env:COUNTRY -version $env:VERSION) -includePlatform; + +RUN New-Item -Path c:\artifacts -ItemType Directory; ` + New-Item -Path c:\bin -ItemType Directory; ` + Start-Process "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\Prerequisite` Components\Open` XML` SDK` 2.5` for` Microsoft` Office\OpenXMLSDKv25.msi" "/qn" -PassThru | Wait-Process; ` + Copy-Item "C:\Program` Files` `(x86`)\Open` XML` SDK\V2.5\lib" "C:\assemblies\OpenXMLSdk" -Recurse; ` + Copy-Item "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\ModernDev\program` files\Microsoft` Dynamics` NAV\*\AL` Development` Environment\ALLanguage.vsix" "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\ALLanguage.zip"; ` + Copy-Item "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\ModernDev\program` files\Microsoft` Dynamics` NAV\*\AL` Development` Environment\System.app" "C:\artifacts\System.app"; ` + Get-ChildItem -Path "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\$env:COUNTRY" -Filter *.app -Recurse | % { Copy-Item $_.FullName "C:/artifacts/" }; ` + Expand-Archive "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\ALLanguage.zip" "C:\alc"; ` + Copy-Item "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\LegacyDlls\program` files\Microsoft` Dynamics` NAV\160\RoleTailored` Client" "C:\assemblies\RoleTailoredClient" -Recurse; ` + Copy-Item "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\ServiceTier\program` files\Microsoft` Dynamics` NAV\160\Service" "C:\assemblies\Service" -Recurse; ` + Copy-Item "C:\bcartifacts.cache\$env:TYPE\$env:VERSION\platform\Test` Assemblies\Mock` Assemblies" "C:\assemblies\MockAssemblies" -Recurse; + +FROM mcr.microsoft.com/windows/nanoserver:$BASE +ARG TYPE +ARG COUNTRY +ARG VERSION +COPY --from=mother c:/alc/extension/bin c:/bin +COPY --from=mother C:/artifacts C:/symbols +COPY --from=mother C:/assemblies c:/assemblies +COPY Dummy.ruleset.json c:\dummy.ruleset.json + +ENV rulesetfile='c:\dummy.ruleset.json' +CMD c:\bin\win32\alc.exe ` + /project:c:\src ` + /packagecachepath:c:\symbols ` + /out:c:\src\app.app ` + /errorlog:c:\src\alc.log ` + /loglevel:Error ` + /ruleset:%rulesetfile% ` + /analyzer:c:\bin\Analyzers\Microsoft.Dynamics.Nav.CodeCop.dll ` + /analyzer:c:\bin\Analyzers\Microsoft.Dynamics.Nav.AppSourceCop.dll ` + /analyzer:c:\bin\Analyzers\Microsoft.Dynamics.Nav.UICop.dll ` + /assemblyprobingpaths:"c:\assemblies\OpenXMLSdk","C:\src\.netpackages","C:\assemblies\RoleTailoredClient","C:\assemblies\Service" diff --git a/Dummy.ruleset.json b/Dummy.ruleset.json new file mode 100644 index 0000000..67500e9 --- /dev/null +++ b/Dummy.ruleset.json @@ -0,0 +1,3 @@ +{ + "name": "Cops ruleset" +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5d65755 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 NAVRockClimber + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 0ca446a..a886285 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,36 @@ # Introduction -TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project. +Dockerfiles for creating an ALC compiler image with all default dependencies from Microsoft. Special conisideration was to limit the number of environment variables to an absolute minimum. If additional parameters and / or dependencies are needed you should override the default docker CMD in your RUN command. -# Getting Started -TODO: Guide users through getting your code up and running on their own system. In this section you can talk about: -1. Installation process -2. Software dependencies -3. Latest releases -4. API references +# Build the image -# Build and Test -TODO: Describe and show how to build your code and run the tests. +For building the image you need to specify certain build arguments: -# Contribute -TODO: Explain how other users and developers can contribute to make your code better. +- BASE: The base tag for the release channel of your architecture e.g.: 1709, 1803, 1909 +- NCHVERSION: The version of Freddy's navcontainerhelper. Only used in the intermediate image for pulling and extracting the artifacts. +- TYPE, COUNTRY, VERSION: These arguments are passed into Freddy Scripts. See the possible values in Freddy description of Get-BCArtifactUrl. -If you want to learn more about creating good readme files then refer the following [guidelines](https://docs.microsoft.com/en-us/azure/devops/repos/git/create-a-readme?view=azure-devops). You can also seek inspiration from the below readme files: -- [ASP.NET Core](https://github.com/aspnet/Home) -- [Visual Studio Code](https://github.com/Microsoft/vscode) -- [Chakra Core](https://github.com/Microsoft/ChakraCore) \ No newline at end of file +The image itself is build by the following:` + +``` +docker build -t : --build-arg BASE= --build-arg NCHVERSION= --build-arg TYPE= --build-arg COUNTRY= --build-arg VERSION=<16.2.13509.13779> -f .\Dockerfile.nano . +``` + +# Run the container + +The most simple variant for running the compiler would be: +``` +docker run -v :C:\src -v -e RulesetFile="c:\src\Cop.ruleset.json" --name alcnano --rm alc: +``` + +If the compile process takes a long time you can try to improve it with granting more memory to the container. This reduced the compile time of about 7000 AL files from over 30 minutes to 3 minutes. +``` +docker run -v :C:\src -v -e RulesetFile="c:\src\Cop.ruleset.json" --memory 10G --name alcnano --rm alc: +``` + +# Choosing the right image + +If you don't have any dotnet declarations you should be able to use the much smaller Nanoserver Image. Elsewise you got to choose the servercore image due to it contains the .Net framework. + +# Converting the output for DevOps + +For usage with DevOps you can use the [Convert-ALC-Output.ps1](https://raw.githubusercontent.com/NAVRockClimber/convert-alc-output/dev/Convert-ALC-Output.ps1). Just pass the log into the script.