Skip to content

Commit

Permalink
Updated build pipeline to use .NET Core 3.1 sdk. (#83)
Browse files Browse the repository at this point in the history
* Updated build pipeline to use .NET Core 3.1 sdk.

Use powershell core built into .NET Core

Updated build script to no longer specify an output path. Specifying an
output path for a project that targets multiple frameworks causes the
binaries to overwrite each other. This results in a broken build.

Updated build scripts to use whatever version of PowerShell is available in the build environment.

* Removed unused variable.

* Reversed order of PowerShell selection.
  • Loading branch information
jimmyca15 committed Jul 10, 2020
1 parent cc0b829 commit d91bf9d
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .pipelines/pipeline.user.windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ environment:
os: windows
runtime:
provider: appcontainer
image: microsoft/dotnet:2.1-sdk
image: mcr.microsoft.com/dotnet/core/sdk:3.1

restore:
commands:
Expand All @@ -26,7 +26,7 @@ build:
- from: 'src'
to: 'Binaries'
include:
- '*/bin/BuildOutput/**/*'
- '*/bin/Release/**/*'

package:
commands:
Expand Down
9 changes: 7 additions & 2 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
call %~dp0build\InstallPowerShellCore.cmd
call %~dp0build\ChoosePowerShell.cmd

%PowerShellCore% "%~dp0build.ps1" %*
IF %ERRORLEVEL% NEQ 0 (

exit /B 1
)

%PowerShell% "%~dp0build.ps1" %*
3 changes: 1 addition & 2 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ param(

$ErrorActionPreference = "Stop"

$BuildRelativePath = "bin\BuildOutput"
$LogDirectory = "$PSScriptRoot\buildlogs"
$Solution = "$PSScriptRoot\Microsoft.FeatureManagement.sln"

Expand All @@ -35,7 +34,7 @@ if ($RestoreOnly)
else
{
# Build
dotnet build -c $BuildConfig "$Solution" /p:OutDir=$BuildRelativePath | Tee-Object -FilePath "$LogDirectory\build.log"
dotnet build -c $BuildConfig "$Solution" | Tee-Object -FilePath "$LogDirectory\build.log"
}

exit $LASTEXITCODE
23 changes: 23 additions & 0 deletions build/ChoosePowerShell.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
:: where.exe does not exist in windows container, application specific test must be used to check for existence

pwsh -Command Write-Host "a"

IF %ERRORLEVEL% == 0 (

set PowerShell=pwsh

exit /B 0
)

PowerShell -Command Write-Host "a"

IF %ERRORLEVEL% == 0 (

set PowerShell=PowerShell

exit /B 0
)

echo Could not find a suitable PowerShell executable.

EXIT /B 1
5 changes: 0 additions & 5 deletions build/InstallPowerShellCore.cmd

This file was deleted.

9 changes: 7 additions & 2 deletions pack.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
call %~dp0build\InstallPowerShellCore.cmd
call %~dp0build\ChoosePowerShell.cmd

%PowerShellCore% "%~dp0pack.ps1" %*
IF %ERRORLEVEL% NEQ 0 (

exit /B 1
)

%PowerShell% "%~dp0pack.ps1" %*
8 changes: 4 additions & 4 deletions pack.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ Note: build.cmd should be run before running this script.

[CmdletBinding()]
param(
[Parameter()]
[ValidateSet('Debug','Release')]
[string]$BuildConfig = "Release"
)

$ErrorActionPreference = "Stop"

$PrebuiltBinariesDir = "bin\BuildOutput"
$PublishRelativePath = "bin\PackageOutput"
$LogDirectory = "$PSScriptRoot\buildlogs"

Expand All @@ -32,9 +34,7 @@ foreach ($project in $targetProjects)
$projectPath = "$PSScriptRoot\src\$project\$project.csproj"
$outputPath = "$PSScriptRoot\src\$project\$PublishRelativePath"

#
# The build system expects pre-built binaries to be in the folder pointed to by 'OutDir'.
dotnet pack -o "$outputPath" /p:OutDir=$PrebuiltBinariesDir "$projectPath" --no-build | Tee-Object -FilePath "$LogDirectory\build.log"
dotnet pack -c $BuildConfig -o "$outputPath" "$projectPath" --no-build | Tee-Object -FilePath "$LogDirectory\build.log"
}

exit $LASTEXITCODE

0 comments on commit d91bf9d

Please sign in to comment.