From 89d4d9b870c23c789997ca6c883498c1f2661604 Mon Sep 17 00:00:00 2001 From: Vitalii Mikhailov Date: Fri, 2 Feb 2024 18:33:20 +0200 Subject: [PATCH] WIP: Fat/Lite Packages (#538) * Added ILMerge back, now with support for .NET core and .NET * Split MSBuild code into smaller files * Added Debug/Release Fat/Lite configurations * Adapted azure pipeline * Added configuration to the display name * Switching to ILRepack.FullAuto for a better control of repacking * Let's test the new ILRepack --- Harmony.sln | 54 ++++--- Harmony/Documentation/Documentation.csproj | 12 +- Harmony/Harmony.csproj | 156 ++++-------------- Harmony/msbuild/_._ | 0 Harmony/msbuild/build.props | 17 ++ Harmony/msbuild/clean.props | 25 +++ Harmony/msbuild/ilrepack.props | 37 +++++ Harmony/msbuild/netstandard.props | 31 ++++ Harmony/msbuild/nuget.props | 75 +++++++++ Harmony/msbuild/package.props | 46 ++++++ Harmony/msbuild/variables.props | 43 +++++ HarmonyTests/HarmonyTests.csproj | 45 ++---- TestLibrary/TestLibrary.csproj | 25 +-- azure-pipelines-job-template.yml | 176 +++++++++++---------- azure-pipelines.yml | 8 + 15 files changed, 463 insertions(+), 287 deletions(-) create mode 100644 Harmony/msbuild/_._ create mode 100644 Harmony/msbuild/build.props create mode 100644 Harmony/msbuild/clean.props create mode 100644 Harmony/msbuild/ilrepack.props create mode 100644 Harmony/msbuild/netstandard.props create mode 100644 Harmony/msbuild/nuget.props create mode 100644 Harmony/msbuild/package.props create mode 100644 Harmony/msbuild/variables.props diff --git a/Harmony.sln b/Harmony.sln index 288f39c6..c94dacee 100644 --- a/Harmony.sln +++ b/Harmony.sln @@ -32,26 +32,44 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestLibrary", "TestLibrary\ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU + ReleaseFat|Any CPU = ReleaseFat|Any CPU + ReleaseLite|Any CPU = ReleaseLite|Any CPU + DebugLite|Any CPU = DebugLite|Any CPU + DebugFat|Any CPU = DebugFat|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {69AEE16A-B6E7-4642-8081-3928B32455DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {69AEE16A-B6E7-4642-8081-3928B32455DF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {69AEE16A-B6E7-4642-8081-3928B32455DF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {69AEE16A-B6E7-4642-8081-3928B32455DF}.Release|Any CPU.Build.0 = Release|Any CPU - {DEE74EFC-29A8-4704-8536-7DA38D3999F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DEE74EFC-29A8-4704-8536-7DA38D3999F7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DEE74EFC-29A8-4704-8536-7DA38D3999F7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DEE74EFC-29A8-4704-8536-7DA38D3999F7}.Release|Any CPU.Build.0 = Release|Any CPU - {9B9DD18C-6EB7-497F-8ED5-699515A840C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9B9DD18C-6EB7-497F-8ED5-699515A840C5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9B9DD18C-6EB7-497F-8ED5-699515A840C5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9B9DD18C-6EB7-497F-8ED5-699515A840C5}.Release|Any CPU.Build.0 = Release|Any CPU - {11F828EC-7C50-48F4-A30D-9BED06837F3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {11F828EC-7C50-48F4-A30D-9BED06837F3A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {11F828EC-7C50-48F4-A30D-9BED06837F3A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {11F828EC-7C50-48F4-A30D-9BED06837F3A}.Release|Any CPU.Build.0 = Release|Any CPU + {69AEE16A-B6E7-4642-8081-3928B32455DF}.ReleaseFat|Any CPU.ActiveCfg = ReleaseFat|Any CPU + {69AEE16A-B6E7-4642-8081-3928B32455DF}.ReleaseFat|Any CPU.Build.0 = ReleaseFat|Any CPU + {69AEE16A-B6E7-4642-8081-3928B32455DF}.ReleaseLite|Any CPU.ActiveCfg = ReleaseLite|Any CPU + {69AEE16A-B6E7-4642-8081-3928B32455DF}.ReleaseLite|Any CPU.Build.0 = ReleaseLite|Any CPU + {69AEE16A-B6E7-4642-8081-3928B32455DF}.DebugLite|Any CPU.ActiveCfg = DebugLite|Any CPU + {69AEE16A-B6E7-4642-8081-3928B32455DF}.DebugLite|Any CPU.Build.0 = DebugLite|Any CPU + {69AEE16A-B6E7-4642-8081-3928B32455DF}.DebugFat|Any CPU.ActiveCfg = DebugFat|Any CPU + {69AEE16A-B6E7-4642-8081-3928B32455DF}.DebugFat|Any CPU.Build.0 = DebugFat|Any CPU + {DEE74EFC-29A8-4704-8536-7DA38D3999F7}.ReleaseFat|Any CPU.ActiveCfg = ReleaseFat|Any CPU + {DEE74EFC-29A8-4704-8536-7DA38D3999F7}.ReleaseFat|Any CPU.Build.0 = ReleaseFat|Any CPU + {DEE74EFC-29A8-4704-8536-7DA38D3999F7}.ReleaseLite|Any CPU.ActiveCfg = ReleaseLite|Any CPU + {DEE74EFC-29A8-4704-8536-7DA38D3999F7}.ReleaseLite|Any CPU.Build.0 = ReleaseLite|Any CPU + {DEE74EFC-29A8-4704-8536-7DA38D3999F7}.DebugLite|Any CPU.ActiveCfg = DebugLite|Any CPU + {DEE74EFC-29A8-4704-8536-7DA38D3999F7}.DebugLite|Any CPU.Build.0 = DebugLite|Any CPU + {DEE74EFC-29A8-4704-8536-7DA38D3999F7}.DebugFat|Any CPU.ActiveCfg = DebugFat|Any CPU + {DEE74EFC-29A8-4704-8536-7DA38D3999F7}.DebugFat|Any CPU.Build.0 = DebugFat|Any CPU + {9B9DD18C-6EB7-497F-8ED5-699515A840C5}.DebugFat|Any CPU.ActiveCfg = Debug|Any CPU + {9B9DD18C-6EB7-497F-8ED5-699515A840C5}.DebugFat|Any CPU.Build.0 = Debug|Any CPU + {9B9DD18C-6EB7-497F-8ED5-699515A840C5}.DebugLite|Any CPU.ActiveCfg = Debug|Any CPU + {9B9DD18C-6EB7-497F-8ED5-699515A840C5}.DebugLite|Any CPU.Build.0 = Debug|Any CPU + {9B9DD18C-6EB7-497F-8ED5-699515A840C5}.ReleaseFat|Any CPU.ActiveCfg = Release|Any CPU + {9B9DD18C-6EB7-497F-8ED5-699515A840C5}.ReleaseFat|Any CPU.Build.0 = Release|Any CPU + {9B9DD18C-6EB7-497F-8ED5-699515A840C5}.ReleaseLite|Any CPU.ActiveCfg = Release|Any CPU + {9B9DD18C-6EB7-497F-8ED5-699515A840C5}.ReleaseLite|Any CPU.Build.0 = Release|Any CPU + {11F828EC-7C50-48F4-A30D-9BED06837F3A}.DebugFat|Any CPU.ActiveCfg = Debug|Any CPU + {11F828EC-7C50-48F4-A30D-9BED06837F3A}.DebugFat|Any CPU.Build.0 = Debug|Any CPU + {11F828EC-7C50-48F4-A30D-9BED06837F3A}.DebugLite|Any CPU.ActiveCfg = Debug|Any CPU + {11F828EC-7C50-48F4-A30D-9BED06837F3A}.DebugLite|Any CPU.Build.0 = Debug|Any CPU + {11F828EC-7C50-48F4-A30D-9BED06837F3A}.ReleaseFat|Any CPU.ActiveCfg = Release|Any CPU + {11F828EC-7C50-48F4-A30D-9BED06837F3A}.ReleaseFat|Any CPU.Build.0 = Release|Any CPU + {11F828EC-7C50-48F4-A30D-9BED06837F3A}.ReleaseLite|Any CPU.ActiveCfg = Release|Any CPU + {11F828EC-7C50-48F4-A30D-9BED06837F3A}.ReleaseLite|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Harmony/Documentation/Documentation.csproj b/Harmony/Documentation/Documentation.csproj index 584cff2c..47b391af 100644 --- a/Harmony/Documentation/Documentation.csproj +++ b/Harmony/Documentation/Documentation.csproj @@ -9,18 +9,14 @@ false - - - - - + false full true DEBUG - + true none false @@ -37,4 +33,8 @@ + + + + diff --git a/Harmony/Harmony.csproj b/Harmony/Harmony.csproj index aa62f2b3..83f2e8cc 100644 --- a/Harmony/Harmony.csproj +++ b/Harmony/Harmony.csproj @@ -2,157 +2,55 @@ netstandard2.0;net35;net452;net472;net48;netcoreapp3.0;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0 - true - Harmony - Andreas Pardeike - Copyright © 2016 - A general non-destructive patch library for .NET and Mono modules - Lib.Harmony - Andreas Pardeike - 0Harmony - true - LICENSE - README.md - https://github.com/pardeike/Harmony - false - Harmony,Mono,Patch,Patching,Runtime,Detour,Detours,Aspect,Aspects - HarmonyLogo.png - https://raw.githubusercontent.com/pardeike/Harmony/master/HarmonyLogo.png - true - obj/docfx-$(TargetFramework).log + true preview + 0Harmony + $(DefaultItemExcludes);Documentation/** - false - $(NoWarn);SYSLIB0011 + $(HarmonyVersion) $(HarmonyVersion) $(HarmonyVersion) - $(HarmonyVersion)$(HarmonyPrerelease) $(HarmonyVersion)$(HarmonyPrerelease) - $(NoWarn);NU5131 + + ReleaseFat;ReleaseLite;DebugLite;DebugFat + + true + obj/docfx-$(TargetFramework).log + false + $(NoWarn);SYSLIB0011;NU5131 + - - - - - true - - - - - false - - - - - - - - - true - - - - - false - true - - - + - - - - - + - - false - full - true - DEBUG - - - - true - none - false - + + + - + + all + + + + all + - - - - - false - - true - - $(TargetsForTfmSpecificContentInPackage);AddRefAssemblyToPackage - - - - - - - - - - ref/netstandard2.0 - - - ref/netstandard2.0 - - - - - - - - - - - - - - - - - + - - - $(MSBuildThisFileDirectory)bin\$(Configuration) - - - - - - - - - - + - - - - - - + diff --git a/Harmony/msbuild/_._ b/Harmony/msbuild/_._ new file mode 100644 index 00000000..e69de29b diff --git a/Harmony/msbuild/build.props b/Harmony/msbuild/build.props new file mode 100644 index 00000000..740d479b --- /dev/null +++ b/Harmony/msbuild/build.props @@ -0,0 +1,17 @@ + + + + + false + full + true + DEBUG + + + + true + none + false + + + \ No newline at end of file diff --git a/Harmony/msbuild/clean.props b/Harmony/msbuild/clean.props new file mode 100644 index 00000000..490684c1 --- /dev/null +++ b/Harmony/msbuild/clean.props @@ -0,0 +1,25 @@ + + + + + + $(MSBuildThisFileDirectory)bin\$(Configuration) + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Harmony/msbuild/ilrepack.props b/Harmony/msbuild/ilrepack.props new file mode 100644 index 00000000..13f5f36b --- /dev/null +++ b/Harmony/msbuild/ilrepack.props @@ -0,0 +1,37 @@ + + + + + + + + true + + + + + false + + + + + + $(Configuration) + false + true + true + true + $(PkgBUTR_ILRepack)\tools\net461\ILRepack.exe + + + + + + + + + + diff --git a/Harmony/msbuild/netstandard.props b/Harmony/msbuild/netstandard.props new file mode 100644 index 00000000..f67f700e --- /dev/null +++ b/Harmony/msbuild/netstandard.props @@ -0,0 +1,31 @@ + + + + + + + false + + true + + $(TargetsForTfmSpecificContentInPackage);AddRefAssemblyToPackage + + + + + + + + + + + + ref/netstandard2.0 + + + ref/netstandard2.0 + + + + + \ No newline at end of file diff --git a/Harmony/msbuild/nuget.props b/Harmony/msbuild/nuget.props new file mode 100644 index 00000000..8d3028d6 --- /dev/null +++ b/Harmony/msbuild/nuget.props @@ -0,0 +1,75 @@ + + + + + + + Lib.Harmony + A general non-destructive patch library for .NET and Mono modules. Contains IL Merged code. Use Lib.Harmony.Lite for a non IL Merged version + + + + + Lib.Harmony.Lite + A general non-destructive patch library for .NET and Mono modules + + + + + + + + true + + + + + false + + + + + + true + Harmony + Andreas Pardeike + Copyright © 2016 + Andreas Pardeike + true + LICENSE + README.md + https://github.com/pardeike/Harmony + false + Harmony,Mono,Patch,Patching,Runtime,Detour,Detours,Aspect,Aspects + HarmonyLogo.png + https://raw.githubusercontent.com/pardeike/Harmony/master/HarmonyLogo.png + $(HarmonyVersion)$(HarmonyPrerelease) + true + + + + + + + + + + + + + + false + + $(TargetsForTfmSpecificContentInPackage);AddEmptyNETDirectoriesToPackage + + + + + + + lib/$(TargetFramework) + + + + + \ No newline at end of file diff --git a/Harmony/msbuild/package.props b/Harmony/msbuild/package.props new file mode 100644 index 00000000..29bd2c30 --- /dev/null +++ b/Harmony/msbuild/package.props @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + true + + + + + false + + + + + + + + true + + + + + false + + + + + + + + + diff --git a/Harmony/msbuild/variables.props b/Harmony/msbuild/variables.props new file mode 100644 index 00000000..1478ac28 --- /dev/null +++ b/Harmony/msbuild/variables.props @@ -0,0 +1,43 @@ + + + + + + + true + + + + + false + + + + + + + + true + + + + + false + + + + + + + + true + + + + + false + + + + + \ No newline at end of file diff --git a/HarmonyTests/HarmonyTests.csproj b/HarmonyTests/HarmonyTests.csproj index cc9fca38..3446aa3c 100644 --- a/HarmonyTests/HarmonyTests.csproj +++ b/HarmonyTests/HarmonyTests.csproj @@ -6,46 +6,30 @@ preview false false + ReleaseFat;ReleaseLite;DebugLite;DebugFat - - - - - true - - - - - false - - - - - - - - - - - false - full - true - DEBUG + + false + full + true + DEBUG - + true none false - + true + + runtime; build; native; contentfiles; analyzers; buildtransitive @@ -63,13 +47,18 @@ - + + + + + + - + mmc diff --git a/TestLibrary/TestLibrary.csproj b/TestLibrary/TestLibrary.csproj index 64f99e75..881cbaba 100644 --- a/TestLibrary/TestLibrary.csproj +++ b/TestLibrary/TestLibrary.csproj @@ -1,33 +1,18 @@ - net35;net452;net472;net48;netcoreapp3.0;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0 - true + net35;net452;net472;net48;netcoreapp3.0;netcoreapp3.1;net5.0;net6.0;net7.0 preview - false false - + + - - false - full - true - DEBUG - - - - true - none - false - - - - + - \ No newline at end of file + diff --git a/azure-pipelines-job-template.yml b/azure-pipelines-job-template.yml index eef11b44..3670b8ba 100644 --- a/azure-pipelines-job-template.yml +++ b/azure-pipelines-job-template.yml @@ -14,9 +14,8 @@ parameters: values: [x86, x64] - name: frameworks type: object -- name: buildConfiguration - type: string - default: Release +- name: buildConfigurations + type: object - name: publishBuild type: boolean default: false @@ -66,15 +65,19 @@ jobs: version: ${{replace(replace(framework, 'coreapp', ''), 'net', '')}}.x packageType: sdk - - bash: "dotnet clean --configuration ${{parameters.buildConfiguration}} && dotnet nuget locals all --clear" - displayName: 'Clean' + - bash: "dotnet nuget locals all --clear" + displayName: 'Clean NuGet' - - task: DotNetCoreCLI@2 - displayName: 'Build' - inputs: - command: build # `dotnet build` implicitly runs `dotnet restore` as well - projects: Harmony.sln - arguments: "--configuration ${{parameters.buildConfiguration}}" + - ${{ each buildConfiguration in parameters.buildConfigurations }}: + - bash: "dotnet clean --configuration ${{buildConfiguration}}" + displayName: 'Clean ${{buildConfiguration}}' + + - task: DotNetCoreCLI@2 + displayName: 'Build ${{buildConfiguration}}' + inputs: + command: build # `dotnet build` implicitly runs `dotnet restore` as well + projects: Harmony.sln + arguments: "--configuration ${{buildConfiguration}}" # For some reason, if mono is installed, above solution restore/build fails when restoring nugets (doesn't fail when only building a project). # Since mono is only needed for running tests in 'mono' runtimeType mode, only install mono after the restore/build. @@ -84,84 +87,85 @@ jobs: # 'dotnet' runtimeType means using `dotnet test`. - ${{ each framework in parameters.frameworks }}: - - ${{ if eq(parameters.runtimeType, 'dotnet') }}: - # dotnet usage notes: - # - `dotnet test` does work for .NET Framework targets, but they still implicitly require mono on non-Windows. - # `dotnet test` for .NET Core targets do not require mono (.NET Core is cross-platform). - # - `dotnet test HarmonyTests`, even with --framework net35, won't run .NET Framework 3.5 tests unless IsTestPlatform is explicitly set - # (since Microsoft.NET.Test.Sdk only sets IsTestProject property for net40+). HarmonyTests.csproj works around this by setting IsTestPlatform for net35. - # - `dotnet test path/to//HarmonyTests.dll --framework ` does work, but there's currently a bug where inline runSettings don't work - # (this is apparently fixed in .NET 5.0+), requiring a runSettings file (which would need to be generated beforehand). So not doing this. - # - Even with the above workaround for running .NET Framework 3.5 tests, there is no CLR 2.0 runtime (or mono equivalent) available to properly test it. - # Both `dotnet test path/to/net35/HarmonyTests.dll --framework net35` and `mono path/to/nunit3-console.exe path/to/net35/HarmonyTests.dll` - # run the tests in 'CLR 4.0 "compatibility mode"' (or the mono equivalent of this). - - task: DotNetCoreCLI@2 - displayName: "Test ${{replace(framework, 'net35', 'net35 in CLR 4.0 \"compatibility mode\"')}}" - condition: succeededOrFailed() - inputs: - command: test - projects: HarmonyTests - arguments: "--no-build --configuration ${{parameters.buildConfiguration}} --framework ${{framework}} --logger \"console;verbosity=normal\" $(blameArg) -- $(runSettingsArgs)" - publishTestResults: true - # .NET Framework on non-Windows implicitly always uses mono. - ${{ if and(ne(parameters.os, 'windows'), not(contains(framework, '.'))) }}: + - ${{ each buildConfiguration in parameters.buildConfigurations }}: + - ${{ if eq(parameters.runtimeType, 'dotnet') }}: + # dotnet usage notes: + # - `dotnet test` does work for .NET Framework targets, but they still implicitly require mono on non-Windows. + # `dotnet test` for .NET Core targets do not require mono (.NET Core is cross-platform). + # - `dotnet test HarmonyTests`, even with --framework net35, won't run .NET Framework 3.5 tests unless IsTestPlatform is explicitly set + # (since Microsoft.NET.Test.Sdk only sets IsTestProject property for net40+). HarmonyTests.csproj works around this by setting IsTestPlatform for net35. + # - `dotnet test path/to//HarmonyTests.dll --framework ` does work, but there's currently a bug where inline runSettings don't work + # (this is apparently fixed in .NET 5.0+), requiring a runSettings file (which would need to be generated beforehand). So not doing this. + # - Even with the above workaround for running .NET Framework 3.5 tests, there is no CLR 2.0 runtime (or mono equivalent) available to properly test it. + # Both `dotnet test path/to/net35/HarmonyTests.dll --framework net35` and `mono path/to/nunit3-console.exe path/to/net35/HarmonyTests.dll` + # run the tests in 'CLR 4.0 "compatibility mode"' (or the mono equivalent of this). + - task: DotNetCoreCLI@2 + displayName: "Test ${{buildConfiguration}} ${{replace(framework, 'net35', 'net35 in CLR 4.0 \"compatibility mode\"')}}" + condition: succeededOrFailed() + inputs: + command: test + projects: HarmonyTests + arguments: "--no-build --configuration ${{buildConfiguration}} --framework ${{framework}} --logger \"console;verbosity=normal\" $(blameArg) -- $(runSettingsArgs)" + publishTestResults: true + # .NET Framework on non-Windows implicitly always uses mono. + ${{ if and(ne(parameters.os, 'windows'), not(contains(framework, '.'))) }}: + testRunTitle: "${{framework}} (${{parameters.os}} mono ${{parameters.architecture}})" + ${{ if or(eq(parameters.os, 'windows'), contains(framework, '.')) }}: # currently no `else` construct in Azure Pipelines + testRunTitle: "${{framework}} (${{parameters.os}} ${{parameters.architecture}})" + + # 'mono' runtimeType is for running .NET Framework tests on Windows (non-Windows will always run .NET Framework tests on mono even via `dotnet test`). + - ${{ if eq(parameters.runtimeType, 'mono') }}: + # Following attempts to replicate the behavior of DotNetCoreCLI test with publishTestResults=true, the main difference being: + # - the usage of mono + vstest.console (since mono + dotnet test doesn't work) + # - the actual test publishing delegated to a followup PublishTestResults task + - bash: | + shopt -s failglob globstar + set -x + # Remove any existing test result files. + for testResultFile in "$(Agent.TempDirectory)"/**/*.trx; do + rm "$testResultFile" + # If there are test attachments, they are in a directory with same name as trx file, excluding the .trx extension. + testResultDir="${testResultFile%.trx}" + if [ -e "$testResultDir" ]; then + rm -r "$testResultDir" + fi + done + # Execute the tests via mono + vstest.console. + mono="$(eval $programFilesCmd)/Mono/bin/mono.exe" + vstest="$(vswhere.exe -latest -property installationPath)/Common7/IDE/CommonExtensions/Microsoft/TestWindow/vstest.console.exe" + "$mono" "$vstest" "HarmonyTests/bin/${{buildConfiguration}}/${{framework}}/HarmonyTests.dll" --Framework:${{framework}} --logger:trx --ResultsDirectory:"$(Agent.TempDirectory)" $(blameArg) -- $(runSettingsArgs) + displayName: "Test ${{buildConfiguration}} ${{replace(framework, 'net35', 'net35 in CLR 4.0 \"compatibility mode\"')}}" + condition: succeededOrFailed() + env: + ${{ if eq(parameters.architecture, 'x86') }}: + programFilesCmd: "cmd //c 'echo %ProgramFiles(x86)%'" # no direct way to access ProgramFiles(x86) env var from within bash + ${{ if ne(parameters.architecture, 'x86') }}: # currently no `else` construct in Azure Pipelines + programFilesCmd: "echo $PROGRAMFILES" + + - ${{ if eq(parameters.runtimeType, 'mono') }}: + - task: PublishTestResults@2 + displayName: "Publish ${{buildConfiguration}} ${{framework}} test results" + condition: succeededOrFailed() + inputs: + buildPlatform: ${{parameters.architecture}} + buildConfiguration: ${{buildConfiguration}} + testResultsFormat: VSTest + testResultsFiles: '**/*.trx' + searchFolder: $(Agent.TempDirectory) testRunTitle: "${{framework}} (${{parameters.os}} mono ${{parameters.architecture}})" - ${{ if or(eq(parameters.os, 'windows'), contains(framework, '.')) }}: # currently no `else` construct in Azure Pipelines - testRunTitle: "${{framework}} (${{parameters.os}} ${{parameters.architecture}})" - # 'mono' runtimeType is for running .NET Framework tests on Windows (non-Windows will always run .NET Framework tests on mono even via `dotnet test`). - - ${{ if eq(parameters.runtimeType, 'mono') }}: - # Following attempts to replicate the behavior of DotNetCoreCLI test with publishTestResults=true, the main difference being: - # - the usage of mono + vstest.console (since mono + dotnet test doesn't work) - # - the actual test publishing delegated to a followup PublishTestResults task + - ${{ if parameters.publishBuild }}: + - ${{ each buildConfiguration in parameters.buildConfigurations }}: + # publish task doesn't support globbing, so have to find the file and output it as a variable. Yes, this is clunky. - bash: | - shopt -s failglob globstar - set -x - # Remove any existing test result files. - for testResultFile in "$(Agent.TempDirectory)"/**/*.trx; do - rm "$testResultFile" - # If there are test attachments, they are in a directory with same name as trx file, excluding the .trx extension. - testResultDir="${testResultFile%.trx}" - if [ -e "$testResultDir" ]; then - rm -r "$testResultDir" - fi + shopt -s failglob + # Expecting only one zip file, but this allows script to error if no such zip file is found. + for buildZipFile in Harmony/bin/Harmony_${{buildConfiguration}}*.zip; do + echo "##vso[task.setvariable variable=buildZipFile]$buildZipFile" done - # Execute the tests via mono + vstest.console. - mono="$(eval $programFilesCmd)/Mono/bin/mono.exe" - vstest="$(vswhere.exe -latest -property installationPath)/Common7/IDE/CommonExtensions/Microsoft/TestWindow/vstest.console.exe" - "$mono" "$vstest" "HarmonyTests/bin/${{parameters.buildConfiguration}}/${{framework}}/HarmonyTests.dll" --Framework:${{framework}} --logger:trx --ResultsDirectory:"$(Agent.TempDirectory)" $(blameArg) -- $(runSettingsArgs) - displayName: "Test ${{replace(framework, 'net35', 'net35 in CLR 4.0 \"compatibility mode\"')}}" - condition: succeededOrFailed() - env: - ${{ if eq(parameters.architecture, 'x86') }}: - programFilesCmd: "cmd //c 'echo %ProgramFiles(x86)%'" # no direct way to access ProgramFiles(x86) env var from within bash - ${{ if ne(parameters.architecture, 'x86') }}: # currently no `else` construct in Azure Pipelines - programFilesCmd: "echo $PROGRAMFILES" - - - ${{ if eq(parameters.runtimeType, 'mono') }}: - - task: PublishTestResults@2 - displayName: "Publish ${{framework}} test results" + displayName: "Find ${{buildConfiguration}} Harmony zip for build artifact publishing" condition: succeededOrFailed() - inputs: - buildPlatform: ${{parameters.architecture}} - buildConfiguration: ${{parameters.buildConfiguration}} - testResultsFormat: VSTest - testResultsFiles: '**/*.trx' - searchFolder: $(Agent.TempDirectory) - testRunTitle: "${{framework}} (${{parameters.os}} mono ${{parameters.architecture}})" - - - ${{ if parameters.publishBuild }}: - # publish task doesn't support globbing, so have to find the file and output it as a variable. Yes, this is clunky. - - bash: | - shopt -s failglob - # Expecting only one zip file, but this allows script to error if no such zip file is found. - for buildZipFile in Harmony/bin/Harmony*.zip; do - echo "##vso[task.setvariable variable=buildZipFile]$buildZipFile" - done - name: FindBuildArtifact - displayName: "Find Harmony zip for build artifact publishing" - condition: succeededOrFailed() - - publish: $(buildZipFile) - displayName: "Publish Harmony zip as build artifact" - artifact: ${{parameters.buildConfiguration}} + - publish: $(buildZipFile) + displayName: "Publish ${{buildConfiguration}} Harmony zip as build artifact" + artifact: ${{buildConfiguration}} diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 50793693..394e9194 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -14,6 +14,7 @@ jobs: os: windows architecture: x64 frameworks: [net35, net452, net472, net48, netcoreapp3.0, netcoreapp3.1, net5.0, net6.0, net7.0, net8.0] + buildConfigurations: [ReleaseFat, ReleaseLite] publishBuild: true - template: azure-pipelines-job-template.yml @@ -22,6 +23,7 @@ jobs: os: windows architecture: x86 frameworks: [net35, net452, net472, net48, netcoreapp3.0, netcoreapp3.1, net5.0, net6.0, net7.0, net8.0] + buildConfigurations: [ReleaseFat, ReleaseLite] - template: azure-pipelines-job-template.yml parameters: @@ -30,6 +32,7 @@ jobs: architecture: x64 runtimeType: mono frameworks: [net35, net452, net472, net48] # mono for .NET Core just delegates to actual .NET Core, so no need for mono .NET Core tests + buildConfigurations: [ReleaseFat, ReleaseLite] - template: azure-pipelines-job-template.yml parameters: @@ -38,6 +41,7 @@ jobs: architecture: x86 runtimeType: mono frameworks: [net35, net452, net472, net48] # mono for .NET Core just delegates to actual .NET Core, so no need for mono .NET Core tests + buildConfigurations: [ReleaseFat, ReleaseLite] - template: azure-pipelines-job-template.yml parameters: @@ -45,6 +49,7 @@ jobs: os: ubuntu architecture: x64 frameworks: [net35, net452, net472, net48, netcoreapp3.0, netcoreapp3.1, net5.0, net6.0, net7.0, net8.0] + buildConfigurations: [ReleaseFat, ReleaseLite] # Without an x86 ubuntu agent and with mono's packaging not multi-arch-safe (can't install x86 mono on x64 ubuntu), we can't test on x86 ubuntu. #- template: azure-pipelines-job-template.yml @@ -52,6 +57,7 @@ jobs: # os: ubuntu # architecture: x86 # frameworks: [net35, net452, net472, net48] # .NET Core x86 is unavailable for non-Windows +# buildConfigurations: [ReleaseFat, ReleaseLite] - template: azure-pipelines-job-template.yml parameters: @@ -59,6 +65,7 @@ jobs: os: macOS architecture: x64 frameworks: [net35, net452, net472, net48, netcoreapp3.0, netcoreapp3.1, net5.0, net6.0, net7.0, net8.0] + buildConfigurations: [ReleaseFat, ReleaseLite] # x86 ubuntu does apply to x86 macOS as well. #- template: azure-pipelines-job-template.yml @@ -66,3 +73,4 @@ jobs: # os: macOS # architecture: x86 # frameworks: [net35, net452, net472, net48] # .NET Core x86 is unavailable for non-Windows +# buildConfigurations: [ReleaseFat, ReleaseLite]