diff --git a/.pipelines/pipeline.user.windows.yml b/.pipelines/pipeline.user.windows.yml
index 28c87dcb..4750d66c 100644
--- a/.pipelines/pipeline.user.windows.yml
+++ b/.pipelines/pipeline.user.windows.yml
@@ -7,16 +7,21 @@ environment:
restore:
commands:
+ - !!defaultcommand
+ name: 'Install .NET'
+ command: 'build/CallPowerShell.cmd'
+ arguments: 'build/install-dotnet.ps1 -RestoreOnly'
- !!defaultcommand
name: 'Restore'
- command: 'build.cmd'
- arguments: '-RestoreOnly'
+ command: 'build/CallPowerShell.cmd'
+ arguments: 'build.ps1 -RestoreOnly'
build:
commands:
- !!buildcommand
name: 'Dotnet Build'
- command: 'build.cmd'
+ command: 'build/CallPowerShell.cmd'
+ arguments: 'build.ps1'
logs:
- from: 'buildlogs'
to: 'Build Logs'
@@ -32,7 +37,8 @@ package:
commands:
- !!buildcommand
name: 'Dotnet Pack'
- command: 'pack.cmd'
+ command: 'build/CallPowerShell.cmd'
+ arguments: 'pack.ps1'
logs:
- from: 'buildlogs'
to: 'Build Logs'
@@ -48,7 +54,8 @@ test:
commands:
- !!testcommand
name: 'Dotnet Test'
- command: 'test.cmd'
+ command: 'build/CallPowerShell.cmd'
+ arguments: 'test.ps1'
fail_on_stderr: false
testresults:
- title: 'Unit Tests'
diff --git a/build.cmd b/build.cmd
deleted file mode 100644
index df877382..00000000
--- a/build.cmd
+++ /dev/null
@@ -1,8 +0,0 @@
-call %~dp0build\ChoosePowerShell.cmd
-
-IF %ERRORLEVEL% NEQ 0 (
-
- exit /B 1
-)
-
-%PowerShell% "%~dp0build.ps1" %*
\ No newline at end of file
diff --git a/build.ps1 b/build.ps1
index 02d792fd..cd90b5c9 100644
--- a/build.ps1
+++ b/build.ps1
@@ -26,15 +26,17 @@ if ((Test-Path -Path $LogDirectory) -ne $true) {
New-Item -ItemType Directory -Path $LogDirectory | Write-Verbose
}
+$dotnet = & "$PSScriptRoot/build/resolve-dotnet.ps1"
+
if ($RestoreOnly)
{
# Restore
- dotnet restore "$Solution"
+ & $dotnet restore "$Solution"
}
else
{
# Build
- dotnet build -c $BuildConfig "$Solution" | Tee-Object -FilePath "$LogDirectory\build.log"
+ & $dotnet build -c $BuildConfig "$Solution" | Tee-Object -FilePath "$LogDirectory\build.log"
}
exit $LASTEXITCODE
diff --git a/build/CallPowerShell.cmd b/build/CallPowerShell.cmd
new file mode 100644
index 00000000..fd8eb280
--- /dev/null
+++ b/build/CallPowerShell.cmd
@@ -0,0 +1 @@
+PowerShell %~dp0..\%*
\ No newline at end of file
diff --git a/build/ChoosePowerShell.cmd b/build/ChoosePowerShell.cmd
deleted file mode 100644
index 45798129..00000000
--- a/build/ChoosePowerShell.cmd
+++ /dev/null
@@ -1,23 +0,0 @@
-:: 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
diff --git a/build/install-dotnet.ps1 b/build/install-dotnet.ps1
new file mode 100644
index 00000000..254a9c24
--- /dev/null
+++ b/build/install-dotnet.ps1
@@ -0,0 +1,10 @@
+# Installs .NET Core 2.1, .NET 5 and .NET 6 for CI/CD environment
+# see: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script#examples
+
+[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
+
+&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version 2.1.816
+
+&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version 5.0.17
+
+&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1')))
diff --git a/build/resolve-dotnet.ps1 b/build/resolve-dotnet.ps1
new file mode 100644
index 00000000..79219a8b
--- /dev/null
+++ b/build/resolve-dotnet.ps1
@@ -0,0 +1,14 @@
+# Resolves dotnet execution path
+# Locations considered include dotnet install script default location and somewhere on path
+$CI_CD_INSTALL_PATH = "$env:LOCALAPPDATA\Microsoft\dotnet\dotnet.exe"
+
+if (Test-Path $CI_CD_INSTALL_PATH)
+{
+ $CI_CD_INSTALL_PATH
+
+ return
+}
+
+$dotnet = Get-Command dotnet.exe -ErrorAction Stop
+
+$dotnet.Source
\ No newline at end of file
diff --git a/examples/ConsoleApp/ConsoleApp.csproj b/examples/ConsoleApp/ConsoleApp.csproj
index c638b298..1230fedf 100644
--- a/examples/ConsoleApp/ConsoleApp.csproj
+++ b/examples/ConsoleApp/ConsoleApp.csproj
@@ -2,13 +2,13 @@
Exe
- net5.0
+ net6.0
Consoto.Banking.AccountService
-
-
+
+
diff --git a/examples/FeatureFlagDemo/FeatureFlagDemo.csproj b/examples/FeatureFlagDemo/FeatureFlagDemo.csproj
index 3bf22dc9..7ab458e3 100644
--- a/examples/FeatureFlagDemo/FeatureFlagDemo.csproj
+++ b/examples/FeatureFlagDemo/FeatureFlagDemo.csproj
@@ -1,7 +1,7 @@
- net5.0
+ net6.0
diff --git a/examples/TargetingConsoleApp/TargetingConsoleApp.csproj b/examples/TargetingConsoleApp/TargetingConsoleApp.csproj
index c638b298..1230fedf 100644
--- a/examples/TargetingConsoleApp/TargetingConsoleApp.csproj
+++ b/examples/TargetingConsoleApp/TargetingConsoleApp.csproj
@@ -2,13 +2,13 @@
Exe
- net5.0
+ net6.0
Consoto.Banking.AccountService
-
-
+
+
diff --git a/pack.cmd b/pack.cmd
deleted file mode 100644
index 209cd5e0..00000000
--- a/pack.cmd
+++ /dev/null
@@ -1,8 +0,0 @@
-call %~dp0build\ChoosePowerShell.cmd
-
-IF %ERRORLEVEL% NEQ 0 (
-
- exit /B 1
-)
-
-%PowerShell% "%~dp0pack.ps1" %*
\ No newline at end of file
diff --git a/pack.ps1 b/pack.ps1
index a05e485c..12434211 100644
--- a/pack.ps1
+++ b/pack.ps1
@@ -29,12 +29,14 @@ if ((Test-Path -Path $LogDirectory) -ne $true) {
New-Item -ItemType Directory -Path $LogDirectory | Write-Verbose
}
+$dotnet = & "$PSScriptRoot/build/resolve-dotnet.ps1"
+
foreach ($project in $targetProjects)
{
$projectPath = "$PSScriptRoot\src\$project\$project.csproj"
$outputPath = "$PSScriptRoot\src\$project\$PublishRelativePath"
- dotnet pack -c $BuildConfig -o "$outputPath" "$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
diff --git a/src/Microsoft.FeatureManagement.AspNetCore/Microsoft.FeatureManagement.AspNetCore.csproj b/src/Microsoft.FeatureManagement.AspNetCore/Microsoft.FeatureManagement.AspNetCore.csproj
index 8e66c36d..767d9b39 100644
--- a/src/Microsoft.FeatureManagement.AspNetCore/Microsoft.FeatureManagement.AspNetCore.csproj
+++ b/src/Microsoft.FeatureManagement.AspNetCore/Microsoft.FeatureManagement.AspNetCore.csproj
@@ -11,7 +11,7 @@
- netstandard2.0;netcoreapp3.1;net5.0
+ netstandard2.0;netcoreapp3.1;net5.0;net6.0
true
false
..\..\build\Microsoft.FeatureManagement.snk
diff --git a/src/Microsoft.FeatureManagement/Microsoft.FeatureManagement.csproj b/src/Microsoft.FeatureManagement/Microsoft.FeatureManagement.csproj
index 3121d633..4959356d 100644
--- a/src/Microsoft.FeatureManagement/Microsoft.FeatureManagement.csproj
+++ b/src/Microsoft.FeatureManagement/Microsoft.FeatureManagement.csproj
@@ -11,7 +11,7 @@
- netstandard2.0;netcoreapp3.1;net5.0
+ netstandard2.0;netcoreapp3.1;net5.0;net6.0
true
false
..\..\build\Microsoft.FeatureManagement.snk
diff --git a/test.cmd b/test.cmd
deleted file mode 100644
index 6b02a979..00000000
--- a/test.cmd
+++ /dev/null
@@ -1,3 +0,0 @@
-cd /D "%~dp0"
-
-dotnet test tests\Tests.FeatureManagement\Tests.FeatureManagement.csproj --logger trx || exit /b 1
diff --git a/test.ps1 b/test.ps1
new file mode 100644
index 00000000..8cf5fdc2
--- /dev/null
+++ b/test.ps1
@@ -0,0 +1,7 @@
+$ErrorActionPreference = "Stop"
+
+$dotnet = & "$PSScriptRoot/build/resolve-dotnet.ps1"
+
+& $dotnet test "$PSScriptRoot\tests\Tests.FeatureManagement\Tests.FeatureManagement.csproj" --logger trx
+
+exit $LASTEXITCODE
\ No newline at end of file
diff --git a/tests/Tests.FeatureManagement/FeatureManagement.cs b/tests/Tests.FeatureManagement/FeatureManagement.cs
index af67fe8e..b2486b93 100644
--- a/tests/Tests.FeatureManagement/FeatureManagement.cs
+++ b/tests/Tests.FeatureManagement/FeatureManagement.cs
@@ -671,7 +671,7 @@ public async Task ThreadsafeSnapshot()
private static void DisableEndpointRouting(MvcOptions options)
{
-#if NET5_0 || NETCOREAPP3_1
+#if NET6_0 || NET5_0 || NETCOREAPP3_1
//
// Endpoint routing is disabled by default in .NET Core 2.1 since it didn't exist.
options.EnableEndpointRouting = false;
diff --git a/tests/Tests.FeatureManagement/Tests.FeatureManagement.csproj b/tests/Tests.FeatureManagement/Tests.FeatureManagement.csproj
index 2b4517bd..1b96ebd8 100644
--- a/tests/Tests.FeatureManagement/Tests.FeatureManagement.csproj
+++ b/tests/Tests.FeatureManagement/Tests.FeatureManagement.csproj
@@ -1,7 +1,7 @@
- netcoreapp2.1;netcoreapp3.1;net5.0
+ netcoreapp2.1;netcoreapp3.1;net5.0;net6.0
false
8.0
@@ -31,6 +31,12 @@
+
+
+
+
+
+