-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
CARE-265: Adding .NET Framework build features
- Loading branch information
Showing
15 changed files
with
306 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Checkout | ||
description: > | ||
Runs actions/checkout. Exists only to centralize which version of the action we use. Intentionally not documented in | ||
Actions.md since it's only meant for internal use. | ||
inputs: | ||
token: | ||
required: false | ||
default: ${{ github.token }} | ||
description: > | ||
The GitHub token to authenticate checkout. Pass in a GitHub personal access token if authenticated submodules are | ||
used. | ||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
submodules: 'recursive' | ||
token: ${{ inputs.token }} |
77 changes: 77 additions & 0 deletions
77
.github/actions/msbuild/Build-DotNetFrameworkSolutionOrProject.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
param ( | ||
[string] $SolutionOrProject, | ||
[string] $Verbosity, | ||
[string] $EnableCodeAnalysis, | ||
[string] $Version, | ||
[string] $Switches) | ||
|
||
function ConvertTo-Array([string] $rawInput) | ||
{ | ||
$rawInput.Replace("`r", "").Split("`n") | ForEach-Object { $PSItem.Trim() } | Where-Object { $PSItem } | ||
} | ||
|
||
Write-Output ".NET version number: $Version" | ||
|
||
if (Test-Path src/Utilities/Lombiq.Gulp.Extensions/Lombiq.Gulp.Extensions.csproj) | ||
{ | ||
Write-Output "::group::Gulp Extensions found. It needs to be explicitly built before the solution." | ||
|
||
# These need to be different than those for msbuild. | ||
$gulpBuildSwitches = ConvertTo-Array @" | ||
--configuration:Release | ||
--nologo | ||
--verbosity:$Verbosity | ||
--warnaserror | ||
--warnAsMessage:MSB3026 | ||
--consoleLoggerParameters:NoSummary | ||
-p:TreatWarningsAsErrors=true | ||
-p:RunAnalyzersDuringBuild=$EnableCodeAnalysis | ||
-p:Retries=4 | ||
-p:RetryDelayMilliseconds=1000 | ||
-p:Version=$Version | ||
"@ | ||
|
||
$startTime = [DateTime]::Now | ||
dotnet build src/Utilities/Lombiq.Gulp.Extensions/Lombiq.Gulp.Extensions.csproj @gulpBuildSwitches | ||
$endTime = [DateTime]::Now | ||
|
||
Write-Output ("Gulp Extensions build took {0:0.###} seconds." -f ($endTime - $startTime).TotalSeconds) | ||
Write-Output "::endgroup::" | ||
} | ||
|
||
# -p:Retries and -p:RetryDelayMilliseconds are used to retry builds when they fail due to random locks. | ||
|
||
$buildSwitches = ConvertTo-Array @" | ||
-p:Configuration=Release | ||
-restore | ||
--verbosity:$Verbosity | ||
--warnaserror | ||
-p:TreatWarningsAsErrors=true | ||
-p:RunAnalyzersDuringBuild=$EnableCodeAnalysis | ||
-p:Retries=4 | ||
-p:RetryDelayMilliseconds=1000 | ||
-p:Version=$Version | ||
$Switches | ||
"@ | ||
|
||
Write-Output "Building solution or project with ``msbuild $SolutionOrProject $($buildSwitches -join " ")``." | ||
|
||
msbuild $SolutionOrProject @buildSwitches | ||
|
||
# Without this, if the msbuild command fails with certain MSB error codes (not build errors), they still won't cause | ||
# this script to fail. | ||
|
||
# error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.1 were not found. To resolve this, install the | ||
# Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET | ||
# Framework Developer Packs at https://aka.ms/msbuild/developerpacks | ||
|
||
if ($?) | ||
{ | ||
Write-Output "Build successful." | ||
Stop-DotNetBuildServers | ||
} | ||
else | ||
{ | ||
Write-Output "::error::Build failed. See the errors above in the build log." | ||
exit 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
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. | ||
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. | ||
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 | ||
# v1.1.3 | ||
uses: microsoft/setup-msbuild@34cfbaee7f672c76950673338facd8a73f637506 | ||
with: | ||
vs-version: "[17.3,]" | ||
|
||
- name: Build and Static Code Analysis | ||
shell: pwsh | ||
working-directory: ${{ inputs.directory }} | ||
run: | | ||
$givenSwitches = @' | ||
${{ inputs.msbuild-switches }} | ||
'@ | ||
$allSwitches = @{ | ||
SolutionOrProject = (Get-ChildItem ${{ inputs.solution-or-project-path }}).FullName | ||
Verbosity = "${{ inputs.verbosity }}" | ||
EnableCodeAnalysis = "${{ inputs.enable-code-analysis }}" | ||
Version = "${{ inputs.publish-version }}" | ||
Switches = $givenSwitches | ||
} | ||
$startTime = [DateTime]::Now | ||
Build-DotNetFrameworkSolutionOrProject @allSwitches | ||
$endTime = [DateTime]::Now | ||
Write-Output ("Solution or project build took {0:0.###} seconds." -f ($endTime - $startTime).TotalSeconds) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,9 +114,8 @@ jobs: | |
- ${{ inputs.timeout-minutes }} | ||
timeout-minutes: ${{ matrix.timeout-minutes }} | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
submodules: 'recursive' | ||
- name: Checkout | ||
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev | ||
|
||
- name: Set up .NET | ||
uses: Lombiq/GitHub-Actions/.github/actions/setup-dotnet@dev | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,9 +88,8 @@ jobs: | |
- ${{ inputs.timeout-minutes }} | ||
timeout-minutes: ${{ matrix.timeout-minutes }} | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
submodules: 'recursive' | ||
- name: Checkout | ||
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev | ||
|
||
- name: Set up .NET | ||
uses: Lombiq/GitHub-Actions/.github/actions/setup-dotnet@dev | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,9 +116,8 @@ jobs: | |
shell: pwsh | ||
timeout-minutes: ${{ inputs.timeout-minutes }} | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
submodules: 'recursive' | ||
- name: Checkout | ||
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev | ||
|
||
- name: Set up .NET | ||
uses: Lombiq/GitHub-Actions/.github/actions/setup-dotnet@dev | ||
|
Oops, something went wrong.