Skip to content

Commit 88d4971

Browse files
committed
Attempt to fix BS build
MSBuild properties are no good, must use env vars instead.
1 parent 9fbc385 commit 88d4971

3 files changed

Lines changed: 18 additions & 9 deletions

File tree

.github/workflows/crossBrowserTesting.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747
Configuration: Release
4848
Tfm: net8.0
4949
DotnetVersion: 8.0.x
50+
ENABLE_BROWSERSTACK: true
5051
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
5152
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
5253
BROWSERSTACK_BUILD_IDENTIFIER: gh-actions-cbt.${{ github.run_number }}.${{ github.run_attempt }}
@@ -74,8 +75,6 @@ jobs:
7475
- name: Force .NET 8 with global.json
7576
run: |
7677
echo '{ "sdk": { "version": "8.0.418", "rollForward": "latestFeature" } }' > global.json
77-
- name: Restore NuGet packages
78-
run: dotnet msbuild /t:Restore /p:BrowserStackEnabled=true
7978
- name: Restore Node modules
8079
run: |
8180
cd CSF.Screenplay.JsonToHtmlReport.Template/src
@@ -86,7 +85,7 @@ jobs:
8685

8786
- name: Run .NET Selenium tests only
8887
id: dotnet_tests
89-
run: dotnet test -c ${{ env.Configuration }} -p:BrowserStackEnabled=true Tests/CSF.Screenplay.Selenium.Tests
88+
run: dotnet test -c ${{ env.Configuration }} Tests/CSF.Screenplay.Selenium.Tests
9089
continue-on-error: true
9190

9291
# Post-test tasks (artifacts, overall status)

Tests/CSF.Screenplay.Selenium.Tests/CSF.Screenplay.Selenium.Tests.csproj

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@
66
<IsPackable>false</IsPackable>
77
<IsTestProject>true</IsTestProject>
88
<RootNamespace>CSF.Screenplay.Selenium</RootNamespace>
9-
<DefineConstants Condition="'$(BrowserStackEnabled)' == 'true'">$(DefineConstants);NO_NUNIT_PARALLELISM</DefineConstants>
9+
<!--
10+
Note that ENABLE_BROWSERSTACK must be set via environment variable and not by MSBuild property.
11+
This is because the BrowserStack SDK re-enters the dotnet build process and does not pass
12+
MSBuild properties forward. This is problematic because during that (inner) build process triggered
13+
by the BS SDK, the property which enables the TestAdapter NuGet reference (below) won't be present,
14+
and the build fails.
15+
16+
By using an env variable instead, it ensures that it's always present.
17+
-->
18+
<DefineConstants Condition="'$(ENABLE_BROWSERSTACK)' == 'true'">$(DefineConstants);NO_NUNIT_PARALLELISM</DefineConstants>
1019
</PropertyGroup>
1120

1221
<ItemGroup>
@@ -24,7 +33,7 @@
2433
<PackageReference Include="Moq" Version="4.20.70" />
2534
<PackageReference Include="AutoFixture.NUnit3" Version="4.18.1" />
2635
<PackageReference Include="AutoFixture.AutoMoq" Version="4.18.1" />
27-
<PackageReference Include="BrowserStack.TestAdapter" Version="0.23.0" Condition="'$(BrowserStackEnabled)' == 'true'" />
36+
<PackageReference Include="BrowserStack.TestAdapter" Version="0.23.0" Condition="'$(ENABLE_BROWSERSTACK)' == 'true'" />
2837
<PackageReference Include="System.Text.Json" Version="9.0.7" />
2938
</ItemGroup>
3039

Tests/CSF.Screenplay.Selenium.Tests/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,17 @@ There are two steps to enabling this, in this project.
3030

3131
[the BrowserStack SDK]: https://www.browserstack.com/blog/introducing-browserstack-sdk/
3232

33-
### An MSBuild property
33+
### An environment variable
3434

35-
When using `dotnet build` or `dotnet test`, include the property `BrowserStack` with a value of `true`.
35+
Before executing `dotnet build` or `dotnet test`, ensure that the environment variable `ENABLE_BROWSERSTACK` is set to the value `true`.
3636
For example:
3737

3838
```cmd
39-
dotnet test -p:BrowserStackEnabled=true
39+
SET ENABLE_BROWSERSTACK="true"
40+
dotnet test
4041
```
4142

42-
This will activate two changes in the `.csproj` file in this directory:
43+
The presence of this environment variable will activate two changes in the `.csproj` file in this directory:
4344

4445
* It will install the BrowserStack SDK NuGet package: `BrowserStack.TestAdapter`
4546
* It will disable NUnit's parallelism feature

0 commit comments

Comments
 (0)