-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathaction.yml
More file actions
105 lines (97 loc) · 4.56 KB
/
Copy pathaction.yml
File metadata and controls
105 lines (97 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: MSBuild .NET Framework Build with Static Code Analysis
description: Builds the .NET Framework solution in the given directory with static code analysis.
inputs:
directory:
required: false
default: .
description: Path to the directory where a solution file can be found.
verbosity:
required: false
default: quiet
description: Verbosity parameter for msbuild.
treat-warnings-as-errors:
required: false
default: 'true'
description: If set to "true", warnings produced during the build will be treated as errors and fail the build.
enable-code-analysis:
required: false
default: 'true'
description: If set to "true", static code analysis is enabled during the build.
publish-version:
required: false
default: 1.${{ github.run_number }}.${{ github.run_attempt }}-${{ github.run_id }}
description: The value given to `msbuild`'s `-Version` switch.
msbuild-switches:
required: false
default: ''
description: >
Additional command line switches given to `msbuild`. You must split these into multiple lines, even the parameter
value.
solution-or-project-path:
required: false
default: '*.sln'
description: >
The path of the solution or project file to be built. If you have exactly one .sln file in the current directory
then this can be omitted. Otherwise make sure to specify it to avoid an "MSB1008: Only one project can be
specified." error that is thrown when the `*.sln` wildcard results in multiple files. To build a project file you
must specify a path that ends with `.csproj`. An example: "./src/*Web/*.Web.csproj". The value is given to
PowerShell's `Get-ChildItem` cmdlet as-is, so grepping is still possible but a name with spaces must be escaped
separately.
create-binary-log:
required: false
default: 'false'
description: >
Configures MSBuild to create a binary log. This is useful to inspect and debug builds. See
https://github.com/dotnet/msbuild/blob/main/documentation/wiki/Binary-Log.md for details.
binary-log-artifact-retention-days:
required: false
default: '14'
description: >
Duration in days after which the artifact of the binary log (if any) will expire. See
https://github.com/actions/upload-artifact#retention-period for more details.
runs:
using: composite
steps:
- name: Setup Scripts
shell: pwsh
run: |
'${{ github.action_path }}' >> $Env:GITHUB_PATH
(Resolve-Path '${{ github.action_path }}/../../../Scripts').Path >> $Env:GITHUB_PATH
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@30375c66a4eea26614e0d39710365f22f8b0af57 # v3.0.0
with:
vs-version: '[17.3,]'
msbuild-architecture: x64
- name: Build and Static Code Analysis
shell: pwsh
working-directory: ${{ inputs.directory }}
# The BuildVersionDisplay parameters are added to automatically support displaying the branch name and commit hash
# as a link to the workflow run in the Orchard Dashboard of an Orchard 1 application that has the
# Lombiq.Hosting.Deployments module (https://github.com/Lombiq/Hosting-Deployments) enabled.
run: |
$givenSwitches = @'
-p:BuildVersionDisplay_BuildText=${{ github.sha }}_${{ github.head_ref }}
-p:BuildVersionDisplay_BuildUrl=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
${{ inputs.msbuild-switches }}
'@
$allSwitches = @{
SolutionOrProject = (Get-ChildItem ${{ inputs.solution-or-project-path }}).FullName
Verbosity = '${{ inputs.verbosity }}'
TreatWarningsAsErrors = '${{ inputs.treat-warnings-as-errors }}'
EnableCodeAnalysis = '${{ inputs.enable-code-analysis }}'
Version = '${{ inputs.publish-version }}'
Switches = $givenSwitches
CreateBinaryLog = $${{ inputs.create-binary-log }}
}
$startTime = [DateTime]::Now
Build-DotNetFrameworkSolutionOrProject @allSwitches
$endTime = [DateTime]::Now
Write-Output ("Solution or project build took {0:0.###} seconds." -f ($endTime - $startTime).TotalSeconds)
- name: Upload MSBuild Binary Log
uses: Lombiq/GitHub-Actions/.github/actions/upload-artifact@issue/OSOE-1308
if: (success() || failure()) && inputs.create-binary-log == 'true'
with:
name: build-binary-log.binlog
path: ${{ inputs.directory }}/build.binlog
if-no-files-found: ignore
retention-days: ${{ inputs.binary-log-artifact-retention-days }}