From 9fe53072340d4eceb4f001eae5a78a7c2b7c482a Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH <38865330+TheCakeIsNaOH@users.noreply.github.com> Date: Tue, 14 May 2019 18:33:40 -0500 Subject: [PATCH 1/7] (GH-1020) Add mono-4.5 configuration Add Mono framework for .NET 4.5 as newer versions of Mono do not have .NET 4.0 anymore. --- .build/compile.step | 24 +-- .build/default.build.settings | 2 +- build.sh | 5 +- lib/NAnt/NAnt.exe.config | 270 ++++++++++++++++++++++++++++++++++ zip.sh | 2 +- 5 files changed, 286 insertions(+), 17 deletions(-) diff --git a/.build/compile.step b/.build/compile.step index b99a2a7209..df0452e71d 100644 --- a/.build/compile.step +++ b/.build/compile.step @@ -21,7 +21,7 @@ - + @@ -106,18 +106,18 @@ - + + commandline="${solution.path} /nologo /property:OutputPath='${msbuild.outputpath}' /property:Configuration=${msbuild.configuration} /verbosity:minimal /noconsolelogger /target:Clean" if="${microsoft.framework.specific != 'mono-4.5'}" /> + commandline="${solution.path} /nologo /property:OutputPath='${msbuild.outputpath}' /property:Configuration=${msbuild.configuration} /verbosity:detailed /toolsversion:4.0 /property:Platform='${msbuild.platform}' /property:TargetFrameworkProfile='' /property:TargetFrameworkVersion=v${framework::get-version(microsoft.framework.specific)} /l:${msbuild.logger};'${dirs.build_results}${path.separator}msbuild-${microsoft.framework.specific}-results.xml'" /> @@ -125,11 +125,11 @@ - + + commandline="${solution.path.windows.mono} /nologo /property:OutputPath='${msbuild.outputpath}' /property:Configuration=${msbuild.configuration} /verbosity:minimal /noconsolelogger /target:Clean" if="${microsoft.framework.specific != 'mono-4.5'}" /> - + + commandline="${solution.path.windows.mono} /nologo /property:OutputPath='${msbuild.outputpath}' /property:Configuration=${msbuild.configuration} /verbosity:minimal /noconsolelogger /target:Clean" if="${microsoft.framework.specific != 'mono-4.5'}" /> - + + commandline="${solution.path} /nologo /property:Configuration=${msbuild.configuration} /verbosity:minimal /noconsolelogger /target:Clean" if="${microsoft.framework.specific != 'mono-4.5'}" /> - + + commandline="${solution.path.windows.mono} /nologo /property:Configuration=${msbuild.configuration} /verbosity:minimal /noconsolelogger /target:Clean" if="${microsoft.framework.specific != 'mono-4.5'}" /> - + diff --git a/build.sh b/build.sh index 648b60c383..cd1b4a558a 100755 --- a/build.sh +++ b/build.sh @@ -25,7 +25,6 @@ displayUsage $1 export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig:/Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig:$PKG_CONFIG_PATH #mono ./lib/NAnt/NAnt.exe /logger:"NAnt.Core.DefaultLogger" /nologo /quiet /f:"$(cd $(dirname "$0"); pwd)/.build/default.build" /D:build.config.settings="$(cd $(dirname "$0"); pwd)/.uppercut" /D:microsoft.framework="mono-3.5" $* -mono --runtime=v4.0.30319 ./lib/NAnt/NAnt.exe /logger:"NAnt.Core.DefaultLogger" /nologo /quiet /f:"$(cd $(dirname "$0"); pwd)/.build/default.build" /D:build.config.settings="$(cd $(dirname "$0"); pwd)/.uppercut" /D:microsoft.framework="mono-4.0" /D:run.ilmerge="false" /D:run.nuget="false" $* - -#/quiet /nologo /debug /verbose /t:"mono-4.0" +mono --runtime=v4.0.30319 ./lib/NAnt/NAnt.exe /logger:"NAnt.Core.DefaultLogger" /nologo /quiet /f:"$(cd $(dirname "$0"); pwd)/.build/default.build" /D:build.config.settings="$(cd $(dirname "$0"); pwd)/.uppercut" /D:microsoft.framework="mono-4.5" /D:run.ilmerge="false" /D:run.nuget="false" $* +#/quiet /nologo /debug /verbose /t:"mono-4.5" \ No newline at end of file diff --git a/lib/NAnt/NAnt.exe.config b/lib/NAnt/NAnt.exe.config index d9542dd09c..ce2b284792 100644 --- a/lib/NAnt/NAnt.exe.config +++ b/lib/NAnt/NAnt.exe.config @@ -2497,6 +2497,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + dmcs + true + linq + true + true + true + true + true + true + true + + + mjs + strict + + + vbnc + true + + + true + true + + + sn + true + + + false + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Unable to locate 'mono' module using pkg-config. Download the Mono development packages from http://www.mono-project.com/downloads/. + + + + + + + + true + + + dmcs + true + linq + true + true + true + true + true + true + true + + + mjs + strict + + + vbnc + true + + + true + true + + + sn + true + + + false + + + true + + + Date: Tue, 14 May 2019 18:38:26 -0500 Subject: [PATCH 2/7] (GH-1020) Dockerfile and Travis to Mono 5.20.1 Update Dockerfile and Travis to Mono v5.20.1. Remove mono-gmcs from what is installed for Travis. Remove mono-gmcs as it is obsolete and no longer available with Mono 5. --- .travis.yml | 4 ++-- docker/Dockerfile.linux | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2676361602..bf92067bca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: csharp mono: - - 3.12.0 + - 5.20.1 install: - - sudo apt-get install mono-devel mono-gmcs + - sudo apt-get install mono-devel - nuget restore src/chocolatey.sln before_script: - chmod +x build.sh diff --git a/docker/Dockerfile.linux b/docker/Dockerfile.linux index 1dea04ead9..4590577b09 100644 --- a/docker/Dockerfile.linux +++ b/docker/Dockerfile.linux @@ -1,4 +1,4 @@ -FROM mono:3.12.1 +FROM mono:5.20.1.19 MAINTAINER Justin Phelps From d2bf426c4bdaed1d7fb619421abf0c72828e8829 Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH <38865330+TheCakeIsNaOH@users.noreply.github.com> Date: Mon, 19 Aug 2019 10:17:43 -0500 Subject: [PATCH 3/7] (doc) Update mono installation instructions in README Update instructions for building choco in Debian and RHEL. Add Fedora instructions for building with DNF. --- README.md | 63 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 7baf606053..571dc55c5e 100644 --- a/README.md +++ b/README.md @@ -137,17 +137,24 @@ Running the build on Windows should produce an artifact that is tested and ready #### Other Platforms ##### Prerequisites: - * Install and configure Mono 3.12.0 (3.8.0 should also work). + * Install and configure Mono 5.20.x (Other versions may work but have not been tested). * [Debian based](http://www.mono-project.com/docs/getting-started/install/linux/#debian-ubuntu-and-derivatives) ```sh +# install prerequisites +sudo apt install apt-transport-https dirmngr gnupg ca-certificates # add the key +sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF -sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF # add the package repository -echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list -# Ubuntu 12.10/12.04 - add this deb as well -echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list +# Debian 10 +echo "deb https://download.mono-project.com/repo/debian stable-buster main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list +# Debian 9 +echo "deb https://download.mono-project.com/repo/debian stable-stretch main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list +# Ubuntu 18.04 +echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list +# Ubuntu 16.04 +echo "deb https://download.mono-project.com/repo/ubuntu stable-xenial main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list # update package indexes sudo apt-get update @@ -155,24 +162,54 @@ sudo apt-get update sudo apt-get install mono-devel -y ``` - * [RPM Based](http://www.mono-project.com/docs/getting-started/install/linux/#centos-fedora-and-derivatives) + * [CentOS/RHEL](https://www.mono-project.com/download/stable/#download-lin-centos) ```sh ### NOT FULLY TESTED AND WORKING ### -# add the EPEL -sudo yum install epel-release -y +# Switch to root shell +su +# Add the EPEL +yum install epel-release -y # Add the key -sudo rpm --import "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF" +pmkeys --import "http://pool.sks-keyservers.net/pks/lookup?op=get&search=0x3fa7e0328081bff6a14da29aa6a19b38d3d831ef" # Add the package repository -sudo yum-config-manager --add-repo http://download.mono-project.com/repo/centos/ +# CentOS/RHEL 8 +su -c 'curl https://download.mono-project.com/repo/centos8-stable.repo | tee /etc/yum.repos.d/mono-centos8-stable.repo' +# CentOS/RHEL 7 +su -c 'curl https://download.mono-project.com/repo/centos7-stable.repo | tee /etc/yum.repos.d/mono-centos7-stable.repo' +# CentOS/RHEL 6 +rpm --import "http://pool.sks-keyservers.net/pks/lookup?op=get&search=0x3fa7e0328081bff6a14da29aa6a19b38d3d831ef" -# update your system -sudo yum update -y +# Update your system +yum update -y # Install mono-devel -sudo yum install mono-devel -y +yum install mono-devel -y +``` + + * [Fedora](https://www.mono-project.com/download/stable/#download-lin-fedora) + +```sh +### NOT FULLY TESTED AND WORKING ### + +# Switch to root shell +su +# Add the key +rpm --import "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF" + +# Add the package repository +# Fedora 29 +su -c 'curl https://download.mono-project.com/repo/centos8-stable.repo | tee /etc/yum.repos.d/mono-centos8-stable.repo' +# Fedora 28 +su -c 'curl https://download.mono-project.com/repo/centos7-stable.repo | tee /etc/yum.repos.d/mono-centos7-stable.repo' + +# Update +dnf update + +# Install mono-devel +dnf install mono-devel -y ``` From a3679bbf25fcd6b214158ce11ab9f4380da06fa4 Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH <38865330+TheCakeIsNaOH@users.noreply.github.com> Date: Thu, 3 Oct 2019 20:47:39 -0500 Subject: [PATCH 4/7] (GH-1020) Docker use code_drop instead of build_output Change the docker container to use `code_drop` folder instead of the `build_output` folder. The zip.sh script uses the `code_drop` rather than `build_output`, so the docker container should follow the same format the zip does. Account for the path change for choco.exe in the wrapper script. --- docker/Dockerfile.linux | 2 +- docker/choco_wrapper | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile.linux b/docker/Dockerfile.linux index 4590577b09..fdcd17f75d 100644 --- a/docker/Dockerfile.linux +++ b/docker/Dockerfile.linux @@ -10,7 +10,7 @@ RUN chmod +x zip.sh RUN ./build.sh WORKDIR /usr/local/bin -RUN ln -s /usr/local/src/choco/build_output/chocolatey +RUN ln -s /usr/local/src/choco/code_drop/chocolatey COPY docker/choco_wrapper /usr/local/bin/choco diff --git a/docker/choco_wrapper b/docker/choco_wrapper index 3aa86b5e5c..745cdf43ce 100755 --- a/docker/choco_wrapper +++ b/docker/choco_wrapper @@ -1,3 +1,3 @@ #!/bin/bash -mono /usr/local/bin/chocolatey/choco.exe "$@" --allow-unofficial +mono /usr/local/bin/chocolatey/console/choco.exe "$@" --allow-unofficial From 43822e3dd686b66bebf7dc0e6c8a5deefbf06ebf Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH <38865330+TheCakeIsNaOH@users.noreply.github.com> Date: Thu, 3 Oct 2019 20:56:17 -0500 Subject: [PATCH 5/7] (GH-1020) Docker add ChocolateyInstall Env Var The ChocolateyInstall environment variable is needed to for docker choco to not output a warning that it cannot find the Chocolatey lib directory and use a different path for packages depending on where the command is run from. Add the environment variable to make it available in the right location. --- docker/Dockerfile.linux | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker/Dockerfile.linux b/docker/Dockerfile.linux index fdcd17f75d..24754056ba 100644 --- a/docker/Dockerfile.linux +++ b/docker/Dockerfile.linux @@ -14,4 +14,6 @@ RUN ln -s /usr/local/src/choco/code_drop/chocolatey COPY docker/choco_wrapper /usr/local/bin/choco +ENV ChocolateyInstall /usr/local/bin/chocolatey + WORKDIR /root From d45658c6270ed59b80529e3bcae333fa025240da Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH <38865330+TheCakeIsNaOH@users.noreply.github.com> Date: Tue, 14 May 2019 18:36:59 -0500 Subject: [PATCH 6/7] (GH-1020) WindowsOnly tests by platform, not ignore Previously, Windows only tests were ignored based on a build compilation symbol `__MonoCS__`. This allowed skipping (ignoring) those tests easily. However newer versions of Mono simply don't use that symbol anymore and the testing aspect does not ignore those tests, ultimately causing them to fail when run in a non-Windows environment. Switch over to using platform that only includes Windows. This will exclude Windows only tests from running on Unix, Linux and MacOS. --- src/chocolatey.tests/TinySpec.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/chocolatey.tests/TinySpec.cs b/src/chocolatey.tests/TinySpec.cs index 460cddcafe..66651afefb 100644 --- a/src/chocolatey.tests/TinySpec.cs +++ b/src/chocolatey.tests/TinySpec.cs @@ -147,18 +147,13 @@ public PendingAttribute(string reason) } } -#if __MonoCS__ - public class WindowsOnlyAttribute : IgnoreAttribute + public class WindowsOnlyAttribute : PlatformAttribute { - public WindowsOnlyAttribute() : base("This is a Windows only test") + public WindowsOnlyAttribute() { + Exclude = "Unix,Linux,MacOsX"; } } -#else - public class WindowsOnlyAttribute : Attribute - { - } -#endif public class IntegrationAttribute : CategoryAttribute { From 22fe302116a54136ec167a2300c941999743967a Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Wed, 25 Mar 2020 09:17:55 -0500 Subject: [PATCH 7/7] (GH-1020) Direct platform only for windows tests Unfortunately, it appears like platform exclusions go by the actual name of "Platform" and attempting to inherit the attribute is ignored by NUnit when selecting platforms to exclude for testing. Add those directly for now until a better alternative is available. --- src/chocolatey.tests/TinySpec.cs | 4 +++- .../infrastructure.app/services/RegistryServiceSpecs.cs | 4 ++++ .../infrastructure.app/services/TemplateServiceSpecs.cs | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/chocolatey.tests/TinySpec.cs b/src/chocolatey.tests/TinySpec.cs index 66651afefb..9ccff1d130 100644 --- a/src/chocolatey.tests/TinySpec.cs +++ b/src/chocolatey.tests/TinySpec.cs @@ -151,8 +151,10 @@ public class WindowsOnlyAttribute : PlatformAttribute { public WindowsOnlyAttribute() { - Exclude = "Unix,Linux,MacOsX"; + Exclude = "Mono, Linux, MacOsX, Linux"; } + + public WindowsOnlyAttribute(string platforms): base(platforms) } public class IntegrationAttribute : CategoryAttribute diff --git a/src/chocolatey.tests/infrastructure.app/services/RegistryServiceSpecs.cs b/src/chocolatey.tests/infrastructure.app/services/RegistryServiceSpecs.cs index cf2d03e470..f2102d1dce 100644 --- a/src/chocolatey.tests/infrastructure.app/services/RegistryServiceSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/services/RegistryServiceSpecs.cs @@ -21,6 +21,7 @@ namespace chocolatey.tests.infrastructure.app.services using chocolatey.infrastructure.services; using Microsoft.Win32; using Moq; + using NUnit.Framework; using Should; using Registry = chocolatey.infrastructure.app.domain.Registry; @@ -47,6 +48,7 @@ protected void reset() } [WindowsOnly] + [Platform(Exclude = "Mono")] public class when_RegistryService_get_installer_keys_is_called : RegistryServiceSpecsBase { private Registry _result; @@ -69,6 +71,7 @@ public void should_not_be_null() } [WindowsOnly] + [Platform(Exclude = "Mono")] public class when_RegistryService_get_key_is_called_for_a_value_that_exists : RegistryServiceSpecsBase { private RegistryKey _result; @@ -111,6 +114,7 @@ public void should_contain_values() } [WindowsOnly] + [Platform(Exclude = "Mono")] public class when_RegistryService_get_key_is_called_for_a_value_that_does_not_exist : RegistryServiceSpecsBase { private RegistryKey _result; diff --git a/src/chocolatey.tests/infrastructure.app/services/TemplateServiceSpecs.cs b/src/chocolatey.tests/infrastructure.app/services/TemplateServiceSpecs.cs index 364dd1bf10..fb9f9f9659 100644 --- a/src/chocolatey.tests/infrastructure.app/services/TemplateServiceSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/services/TemplateServiceSpecs.cs @@ -26,6 +26,7 @@ namespace chocolatey.tests.infrastructure.app.services using chocolatey.infrastructure.app.templates; using chocolatey.infrastructure.filesystem; using Moq; + using NUnit.Framework; using Should; public class TemplateServiceSpecs @@ -373,6 +374,7 @@ public override void BeforeEachSpec() [Fact] [WindowsOnly] + [Platform(Exclude = "Mono")] public void should_generate_all_files_and_directories() { because(); @@ -394,6 +396,7 @@ public void should_generate_all_files_and_directories() [Fact] [WindowsOnly] + [Platform(Exclude = "Mono")] public void should_generate_all_files_and_directories_even_with_outputdirectory() { config.OutputDirectory = "c:\\packages";