Skip to content

Commit

Permalink
More cleanup of .NET bindings project files
Browse files Browse the repository at this point in the history
These changes should allow the .NET bindings to go from a clean
directory to a fully built and configured .NET bindings with
properly embedded resources, providing that the machine is properly
configured to build the project from the command line with Bazel.
This eliminates a barrier to entry with respect to using a .NET
IDE (Visual Studio and Visual Studio for Mac) to build the bindings
without taking some manual steps first (like building the JavaScript
automation atoms and the web server for running tests against).
  • Loading branch information
jimevans committed Apr 28, 2020
1 parent 16ff1ab commit 8a7e58d
Show file tree
Hide file tree
Showing 15 changed files with 98 additions and 30 deletions.
45 changes: 32 additions & 13 deletions dotnet/src/webdriver/WebDriver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,41 @@
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
</ItemGroup>

<ItemGroup>
<Folder Include="Properties\" />
<ItemGroup Condition="'$(OS)' == 'WINDOWS_NT'">
<EmbeddedResource Include="$(ProjectDir)..\..\..\third_party\js\selenium\webdriver.json">
<Visible>False</Visible>
<LogicalName>webdriver_prefs.json</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="$(ProjectDir)..\..\..\bazel-bin\javascript\webdriver\atoms\get-attribute.js">
<Visible>False</Visible>
<LogicalName>get-attribute.js</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="$(ProjectDir)..\..\..\bazel-bin\javascript\atoms\fragments\is-displayed.js">
<Visible>False</Visible>
<LogicalName>is-displayed.js</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="$(ProjectDir)..\..\..\bazel-bin\javascript\atoms\fragments\find-elements.js">
<Visible>False</Visible>
<LogicalName>find-elements.js</LogicalName>
</EmbeddedResource>
</ItemGroup>

<ItemGroup Condition="'$(BuildSystem)' == 'buck'">
<EmbeddedResource Include="$(MSBuildProjectDirectory)\..\..\..\buck-out\gen\third_party\js\selenium\webdriver_prefs\webdriver_prefs">
<ItemGroup Condition="'$(OS)' != 'WINDOWS_NT'">
<EmbeddedResource Include="$(ProjectDir)../../../third_party/js/selenium/webdriver.json">
<Visible>False</Visible>
<LogicalName>webdriver_prefs.json</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="$(ProjectDir)../../../bazel-bin/javascript/webdriver/atoms/get-attribute.js">
<Visible>False</Visible>
<LogicalName>WebDriver.FirefoxPreferences</LogicalName>
<LogicalName>get-attribute.js</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildProjectDirectory)\..\..\..\buck-out\gen\javascript\webdriver\atoms\get-attribute.js">
<EmbeddedResource Include="$(ProjectDir)../../../bazel-bin/javascript/webdriver/atoms/is-displayed.js">
<Visible>False</Visible>
<LogicalName>getAttribute.js</LogicalName>
<LogicalName>is-displayed.js</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildProjectDirectory)\..\..\..\buck-out\gen\javascript\atoms\fragments\is-displayed.js">
<EmbeddedResource Include="$(ProjectDir)../../../bazel-bin/javascript/webdriver/atoms/find-elements.js">
<Visible>False</Visible>
<LogicalName>isDisplayed.js</LogicalName>
<LogicalName>find-elements.js</LogicalName>
</EmbeddedResource>
</ItemGroup>

Expand All @@ -119,12 +138,12 @@
<Reference Include="System.IO.Compression" />
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(OS)' == 'Windows_NT'">
<Exec Command="echo Copying Firefox preferences file from $(ProjectDir)..\..\..\third_party\js\selenium\webdriver.json&#xD;&#xA;copy /y &quot;$(ProjectDir)..\..\..\third_party\js\selenium\webdriver.json&quot; &quot;$(TargetDir)&quot; &gt; NUL&#xD;&#xA;&#xD;&#xA;if not exist &quot;$(TargetDir)get-attribute.js&quot; (&#xD;&#xA; echo Copying getAttribute atom&#xD;&#xA; copy /y &quot;$(ProjectDir)..\..\..\bazel-bin\javascript\webdriver\atoms\get-attribute.js&quot; &quot;$(TargetDir)get-attribute.js&quot; &gt; NUL&#xD;&#xA;) else (&#xD;&#xA; echo Found getAttribute atom at $(TargetDir)get-attribute.js.&#xD;&#xA;)&#xD;&#xA;&#xD;&#xA;if not exist &quot;$(TargetDir)is-displayed.js&quot; (&#xD;&#xA; echo Copying isDisplayed atom&#xD;&#xA; copy /y &quot;$(ProjectDir)..\..\..\bazel-bin\javascript\atoms\fragments\is-displayed.js&quot; &quot;$(TargetDir)is-displayed.js&quot; &gt; NUL&#xD;&#xA;) else (&#xD;&#xA; echo Found isDisplayed atom at $(TargetDir)is-displayed.js.&#xD;&#xA;)&#xD;&#xA;&#xD;&#xA;if not exist &quot;$(TargetDir)find-elements.js&quot; (&#xD;&#xA; echo Copying findElements atom&#xD;&#xA; copy /y &quot;$(ProjectDir)..\..\..\bazel-bin\javascript\atoms\fragments\find-elements.js&quot; &quot;$(TargetDir)find-elements.js&quot; &gt; NUL&#xD;&#xA;) else (&#xD;&#xA; echo Found findElements atom at $(TargetDir)find-elements.js.&#xD;&#xA;)&#xD;&#xA;" />
<Target Name="PreBuild" BeforeTargets="PreBuildEvent" Condition="'$(OS)' == 'Windows_NT'">
<Exec Command="call $(ProjectDir)WebDriver.csproj.prebuild.cmd $(ProjectDir)" />
</Target>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent" Condition="'$(OS)' == 'Windows_NT'">
<Exec Command="if not exist &quot;$(ProjectDir)..\..\..\bazel-bin\javascript\webdriver\atoms\get-attribute.js&quot; (&#xD;&#xA; echo Building getAttribute atom&#xD;&#xA; pushd &quot;$(ProjectDir)..\..\..&quot;&#xD;&#xA; bazel build //javascript/webdriver/atoms:get-attribute.js&#xD;&#xA; popd&#xD;&#xA;)&#xD;&#xA;&#xD;&#xA;if not exist &quot;$(ProjectDir)..\..\..\bazel-bin\javascript\atoms\fragments\is-displayed.js&quot; (&#xD;&#xA; echo Building isDisplayed atom&#xD;&#xA; pushd &quot;$(ProjectDir)..\..\..&quot;&#xD;&#xA; bazel build //javascript/atoms/fragments:is-displayed.js&#xD;&#xA; popd&#xD;&#xA;)&#xD;&#xA;&#xD;&#xA;if not exist &quot;$(ProjectDir)..\..\..\bazel-bin\javascript\atoms\fragments\find-elements.js&quot; (&#xD;&#xA; echo Building findElements atom&#xD;&#xA; pushd &quot;$(ProjectDir)..\..\..&quot;&#xD;&#xA; bazel build //javascript/atoms/fragments:find-elements.js&#xD;&#xA; popd&#xD;&#xA;)&#xD;&#xA;" />
<Target Name="PreBuildNonWindows" BeforeTargets="PreBuildEvent" Condition="'$(OS)' != 'Windows_NT'">
<Exec Command="$(ProjectDir)WebDriver.csproj.prebuild.sh $(ProjectDir)" />
</Target>

</Project>
21 changes: 21 additions & 0 deletions dotnet/src/webdriver/WebDriver.csproj.prebuild.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@echo off
if not exist "%1..\..\..\bazel-bin\javascript\webdriver\atoms\get-attribute.js" (
echo Building getAttribute atom
pushd "%1..\..\.."
bazel build //javascript/webdriver/atoms:get-attribute.js
popd
)

if not exist "%1..\..\..\bazel-bin\javascript\atoms\fragments\is-displayed.js" (
echo Building isDisplayed atom
pushd "%1..\..\.."
bazel build //javascript/atoms/fragments:is-displayed.js
popd
)

if not exist "%1..\..\..\bazel-bin\javascript\atoms\fragments\find-elements.js" (
echo Building findElements atom
pushd "%1..\..\.."
bazel build //javascript/atoms/fragments:find-elements.js
popd
)
18 changes: 18 additions & 0 deletions dotnet/src/webdriver/WebDriver.csproj.prebuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
if [[ ! -f "$1..\..\..\bazel-bin\javascript\webdriver\atoms\get-attribute.js" ]]
then
echo "Building getAttribute atom"
bazel build //javascript/webdriver/atoms:get-attribute.js
fi

if [[ ! -f "$1..\..\..\bazel-bin\javascript\atoms\fragments\is-displayed.js" ]]
then
echo "Building isDisplayed atom"
bazel build //javascript/atoms/fragments:is-displayed.js
fi

if if [[ ! -f "$1..\..\..\bazel-bin\javascript\atoms\fragments\find-elements.js" ]]
then
echo "Building findElements atom"
bazel build //javascript/atoms/fragments:find-elements.js
fi
2 changes: 1 addition & 1 deletion dotnet/test/chrome/WebDriver.Chrome.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net47;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net471;netcoreapp2.1</TargetFrameworks>
<AssemblyName>WebDriver.Chrome.Tests</AssemblyName>
</PropertyGroup>

Expand Down
10 changes: 6 additions & 4 deletions dotnet/test/common/WebDriver.Common.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net47;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net471;netcoreapp2.1</TargetFrameworks>
<AssemblyName>WebDriver.Common.Tests</AssemblyName>
<RootNamespace>OpenQA.Selenium</RootNamespace>
</PropertyGroup>
Expand All @@ -25,8 +25,6 @@
</ItemGroup>

<ItemGroup>
<None Remove="BUCK" />
<None Remove="build.desc" />
<None Remove="Settings.StyleCop" />
</ItemGroup>

Expand Down Expand Up @@ -57,7 +55,11 @@
</ItemGroup>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent" Condition="'$(OS)' == 'Windows_NT'">
<Exec Command="if not exist &quot;$(ProjectDir)..\..\..\bazel-bin\java\client\test\org\openqa\selenium\environment\appserver_deploy.jar&quot; (&#xD;&#xA; echo Building test web server&#xD;&#xA; pushd &quot;$(ProjectDir)..\..\..&quot;&#xD;&#xA; bazel build //java/client/test/org/openqa/selenium/environment:appserver_deploy.jar&#xD;&#xA; popd&#xD;&#xA;)&#xD;&#xA;" />
<Exec Command="call &quot;$(ProjectDir)WebDriver.Common.Tests.csproj.prebuild.cmd&quot; &quot;$(ProjectDir)&quot;" />
</Target>

<Target Name="PreBuildNonWindows" BeforeTargets="PreBuildEvent" Condition="'$(OS)' != 'Windows_NT'">
<Exec Command="$(ProjectDir)WebDriver.Common.Tests.csproj.prebuild.sh $(ProjectDir)" />
</Target>

</Project>
6 changes: 6 additions & 0 deletions dotnet/test/common/WebDriver.Common.Tests.csproj.prebuild.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if not exist "%1..\..\..\bazel-bin\java\client\test\org\openqa\selenium\environment\appserver_deploy.jar" (
echo Building test web server
pushd "%1..\..\.."
bazel build //java/client/test/org/openqa/selenium/environment:appserver_deploy.jar
popd
)
6 changes: 6 additions & 0 deletions dotnet/test/common/WebDriver.Common.Tests.csproj.prebuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
if [[ ! -f "%1..\..\..\bazel-bin\java\client\test\org\openqa\selenium\environment\appserver_deploy.jar" ]]
then
echo "Building test web server"
bazel build //java/client/test/org/openqa/selenium/environment:appserver_deploy.jar
fi
2 changes: 1 addition & 1 deletion dotnet/test/edge/WebDriver.Edge.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net47;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net471;netcoreapp2.1</TargetFrameworks>
<AssemblyName>WebDriver.Edge.Tests</AssemblyName>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion dotnet/test/firefox/WebDriver.Firefox.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net47;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net471;netcoreapp2.1</TargetFrameworks>
<AssemblyName>WebDriver.Firefox.Tests</AssemblyName>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion dotnet/test/ie/WebDriver.IE.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net47;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net471;netcoreapp2.1</TargetFrameworks>
<AssemblyName>WebDriver.IE.Tests</AssemblyName>
<RootNamespace>OpenQA.Selenium.IE</RootNamespace>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion dotnet/test/opera/WebDriver.Opera.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net47;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net471;netcoreapp2.1</TargetFrameworks>
<AssemblyName>WebDriver.Opera.Tests</AssemblyName>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion dotnet/test/remote/WebDriver.Remote.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net47;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net471;netcoreapp2.1</TargetFrameworks>
<AssemblyName>WebDriver.Remote.Tests</AssemblyName>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion dotnet/test/safari/WebDriver.Safari.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net47;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net471;netcoreapp2.1</TargetFrameworks>
<AssemblyName>WebDriver.Safari.Tests</AssemblyName>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion dotnet/test/support/WebDriver.Support.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net47;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net471;netcoreapp2.1</TargetFrameworks>
<AssemblyName>WebDriver.Support.Tests</AssemblyName>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net47;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net471;netcoreapp2.1</TargetFrameworks>
<AssemblyName>Selenium.WebDriverBackedSelenium.Tests</AssemblyName>
</PropertyGroup>

Expand Down Expand Up @@ -44,10 +44,6 @@
</None>
</ItemGroup>

<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
Expand Down

0 comments on commit 8a7e58d

Please sign in to comment.