-
Notifications
You must be signed in to change notification settings - Fork 9
/
Selenium.WebDriver.MSEdgeDriver.targets
96 lines (80 loc) · 5.85 KB
/
Selenium.WebDriver.MSEdgeDriver.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildThisFileDirectory)DefinePropertiesMSEdgeDriver.targets" />
<Target Name="DefinePropertiesMSEdgeDriver" BeforeTargets="BeforeClean;BeforeBuild;BeforePublish;ChmodMsEdgeDriver" Condition="'$(MsEdgeDriverTargetPath)' == ''">
<!--
On a Non-SDK style project, and at the first build, "DefineProperties*.targets"
will not be imported and the driver file will not be copied into the output folder,
due to restoring "packages" folder is too late.
To avoid this problem, this target reevaluates "DefineProperties*.targets" if necessary
before the "Build" target.
-->
<!-- Detect OS platform -->
<PropertyGroup>
<WebDriverPlatform Condition=" '$(WebDriverPlatform)' == '' And '$(RuntimeIdentifier.StartsWith("win"))'=='True' ">win32</WebDriverPlatform>
<WebDriverPlatform Condition=" '$(WebDriverPlatform)' == '' And '$(RuntimeIdentifier.StartsWith("osx"))'=='True' ">mac64</WebDriverPlatform>
<WebDriverPlatform Condition=" '$(WebDriverPlatform)' == '' And '$(RuntimeIdentifier.StartsWith("linux"))'=='True' ">linux64</WebDriverPlatform>
<WebDriverPlatform Condition=" '$(WebDriverPlatform)' == '' And '$(OS)' == 'Windows_NT' ">win32</WebDriverPlatform>
<WebDriverPlatform Condition=" '$(WebDriverPlatform)' == '' And '$(OS)' == 'Unix' And Exists ('/Applications') ">mac64</WebDriverPlatform>
<WebDriverPlatform Condition=" '$(WebDriverPlatform)' == '' And '$(OS)' == 'Unix' ">linux64</WebDriverPlatform>
</PropertyGroup>
<PropertyGroup>
<MsEdgeDriverName Condition="'$(MsEdgeDriverName)' == '' And '$(WebDriverPlatform)' == 'win32'">msedgedriver.exe</MsEdgeDriverName>
<MsEdgeDriverName Condition="'$(MsEdgeDriverName)' == ''">msedgedriver</MsEdgeDriverName>
</PropertyGroup>
<PropertyGroup>
<MsEdgeDriverSrcPath Condition=" '$(MsEdgeDriverSrcPath)' == '' ">$(MSBuildThisFileDirectory)..\driver\$(WebDriverPlatform)\$(MsEdgeDriverName)</MsEdgeDriverSrcPath>
<MsEdgeDriverTargetPath Condition=" '$(MsEdgeDriverTargetPath)' == '' ">$(TargetDir)</MsEdgeDriverTargetPath>
</PropertyGroup>
<!-- Detect that the project type is Web or Not. -->
<PropertyGroup Condition="'$(ProjectTypeIsWeb)' == ''">
<ProjectTypeGuidsPadded Condition="'$(ProjectTypeGuidsPadded)' == ''">;$(ProjectTypeGuids);</ProjectTypeGuidsPadded>
<!-- Reference: http://www.mztools.com/Articles/2008/MZ2008017.aspx -->
<!-- HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\Projects -->
<ProjectTypeIsWeb Condition="$(ProjectTypeGuidsPadded.IndexOf(';{349c5851-65df-11da-9384-00065b846f21};')) != -1">true</ProjectTypeIsWeb>
<ProjectTypeIsWeb Condition="'$(ProjectTypeIsWeb)' == ''">false</ProjectTypeIsWeb>
</PropertyGroup>
<!-- Detect definition of compilation symbol that is "_PUBLISH_MSEDGEDRIVER", or "PublishMsEdgeDriver" msbuild property. -->
<PropertyGroup Condition="'$(PublishMsEdgeDriver)' == ''">
<DefineConstantsPadded Condition="'$(DefineConstantsPadded)' == ''">;$(DefineConstants);</DefineConstantsPadded>
<PublishMsEdgeDriver Condition="$(DefineConstantsPadded.IndexOf(';_PUBLISH_MSEDGEDRIVER;')) != -1">true</PublishMsEdgeDriver>
<PublishMsEdgeDriver Condition="'$(PublishMsEdgeDriver)' == ''">false</PublishMsEdgeDriver>
</PropertyGroup>
<!-- Setup driver file as project item if publishing driver file is enabled. -->
<ItemGroup Condition="'$(PublishMsEdgeDriver)|$(ProjectTypeIsWeb)' == 'true|true'">
<None Include="$(MsEdgeDriverSrcPath)">
<Link>$(MsEdgeDriverName)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</None>
</ItemGroup>
<ItemGroup Condition="'$(PublishMsEdgeDriver)|$(ProjectTypeIsWeb)' == 'true|false'">
<Content Include="$(MsEdgeDriverSrcPath)">
<Link>$(MsEdgeDriverName)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
</ItemGroup>
</Target>
<Target Name="DumpPropertiesMsEdgeDriver" BeforeTargets="AfterClean;AfterBuild;CopyMsEdgeDriverToBin" Condition="'$(DumpPropertiesMsEdgeDriver)' == 'true'">
<Message Importance="high" Text="MsEdgeDriverName is [$(MsEdgeDriverName)]" />
<Message Importance="high" Text="MsEdgeDriverSrcPath is [$(MsEdgeDriverSrcPath)]" />
<Message Importance="high" Text="MsEdgeDriverTargetPath is [$(MsEdgeDriverTargetPath)]" />
<Message Importance="high" Text="ProjectTypeIsWeb is [$(ProjectTypeIsWeb)]" />
<Message Importance="high" Text="PublishMsEdgeDriver is [$(PublishMsEdgeDriver)]" />
<Message Importance="high" Text="WebDriverPlatform is [$(WebDriverPlatform)]" />
</Target>
<Target Name="ChmodMsEdgeDriver" BeforeTargets="BeforeBuild">
<Exec Command="chmod +x "$(MsEdgeDriverSrcPath)"" Condition=" '$(OS)' != 'Windows_NT' AND '$(WebDriverPlatform)' != 'win32'" />
</Target>
<!-- If publishing driver file is disabled (it's default behavior), define "copy" and "clean" build task. -->
<Target Name="CopyMsEdgeDriverToBin" BeforeTargets="AfterBuild" Condition="'$(PublishMsEdgeDriver)' == 'false'">
<Copy SourceFiles="$(MsEdgeDriverSrcPath)" DestinationFiles="$(MsEdgeDriverTargetPath)$(MsEdgeDriverName)" SkipUnchangedFiles="true"></Copy>
<Message Text="sourcefiles: $(MsEdgeDriverSrcPath)" />
<Message Text="destinationfiles: $(MsEdgeDriverTargetPath)$(MsEdgeDriverName)" Importance="high" />
</Target>
<Target Name="DeleteMsEdgeDriverFromBin" BeforeTargets="AfterClean" Condition="'$(PublishMsEdgeDriver)' == 'false'">
<Delete Files="$(MsEdgeDriverTargetPath)$(MsEdgeDriverName)"></Delete>
</Target>
</Project>