1<Project Sdk="Microsoft.NET.Sdk">
2  <!--
3    Licensed to the Apache Software Foundation(ASF) under one
4    or more contributor license agreements.See the NOTICE file
5    distributed with this work for additional information
6    regarding copyright ownership.The ASF licenses this file
7    to you under the Apache License, Version 2.0 (the
8    "License"); you may not use this file except in compliance
9    with the License. You may obtain a copy of the License at
10
11  	  http://www.apache.org/licenses/LICENSE-2.0
12
13    Unless required by applicable law or agreed to in writing,
14    software distributed under the License is distributed on an
15    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16    KIND, either express or implied. See the License for the
17    specific language governing permissions and limitations
18    under the License.
19  -->
20
21  <PropertyGroup>
22    <ThriftVersion>0.18.0</ThriftVersion>
23    <ThriftVersionOutput>Thrift version $(ThriftVersion)</ThriftVersionOutput>
24    <TargetFramework>net6.0</TargetFramework>
25    <Version>$(ThriftVersion).0</Version>
26    <AssemblyName>Thrift.PublicInterfaces.Compile.Tests</AssemblyName>
27    <PackageId>Thrift.PublicInterfaces.Compile.Tests</PackageId>
28    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
29    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
30    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
31    <GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
32    <Nullable>enable</Nullable>
33  </PropertyGroup>
34
35  <ItemGroup>
36    <ProjectReference Include="../../Thrift/Thrift.csproj" />
37  </ItemGroup>
38
39  <ItemGroup>
40    <PackageReference Include="System.ServiceModel.Primitives" Version="4.9.0" />
41  </ItemGroup>
42
43  <ItemGroup>
44    <PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" />
45  </ItemGroup>
46
47  <Target Name="PreBuild" BeforeTargets="_GenerateRestoreProjectSpec;Restore;Compile">
48    <!-- Check on the path -->
49    <Exec Condition="'$(OS)' == 'Windows_NT'" Command="where thrift" ConsoleToMSBuild="true">
50      <Output TaskParameter="ConsoleOutput" PropertyName="PathToThrift" />
51    </Exec>
52    <Exec Condition="'$(OS)' != 'Windows_NT'" Command="which thrift || true" ConsoleToMSBuild="true">
53      <Output TaskParameter="ConsoleOutput" PropertyName="PathToThrift" />
54    </Exec>
55    <!-- Check in the current directory -->
56    <CreateProperty Condition="Exists('thrift')" Value="thrift">
57      <Output TaskParameter="Value" PropertyName="PathToThrift" />
58    </CreateProperty>
59    <!-- Check for the root projects output -->
60    <CreateProperty Condition="Exists('$(ProjectDir)/../../../../compiler/cpp/thrift')" Value="$(ProjectDir)/../../../../compiler/cpp/thrift">
61      <Output TaskParameter="Value" PropertyName="PathToThrift" />
62    </CreateProperty>
63    <Error Condition="!Exists('$(PathToThrift)')" Text="Thrift executable could not be found." />
64    <!-- Make sure the thrift version found is the same as the projects version -->
65    <Exec Command="$(PathToThrift) -version" ConsoleToMSBuild="true">
66      <Output TaskParameter="ConsoleOutput" PropertyName="ThriftBinaryVersion" />
67    </Exec>
68    <Error Condition="$('$(ThriftBinaryVersion)'::StartsWith('$(ThriftVersionOutput)')) == true" Text="Thrift version returned: '$(ThriftBinaryVersion)' is not equal to the projects version '$(ThriftVersionOutput)'." />
69    <Message Importance="high" Text="Generating tests with thrift binary: '$(PathToThrift)'" />
70    <!-- Generate the thrift test files -->
71    <Exec Command="$(PathToThrift) -gen netstd:wcf,union,serial,net6 -r ./CassandraTest.thrift" />
72    <Exec Command="$(PathToThrift) -gen netstd:wcf,union,serial,net6 -r ./optional_required_default.thrift" />
73    <Exec Command="$(PathToThrift) -gen netstd:wcf,union,serial,net6 -r ./name_conflicts.thrift" />
74    <Exec Command="$(PathToThrift) -gen netstd:wcf,union,serial,net6 -r ./../../../../test/ThriftTest.thrift" />
75    <Exec Command="$(PathToThrift) -gen netstd:wcf,union,serial,net6 -r ./../../../../contrib/fb303/if/fb303.thrift" />
76    <Exec Command="$(PathToThrift) -gen netstd:wcf,union,serial,net6 -r ./Thrift5253.thrift" />
77    <Exec Command="$(PathToThrift) -gen netstd:wcf,union,serial,net6 -r ./Thrift5320.thrift" />
78    <Exec Command="$(PathToThrift) -gen netstd:wcf,union,serial,net6 -r ./Thrift5382.thrift" />
79  </Target>
80
81</Project>
82