Files
spark/src/Directory.Build.targets
T

189 lines
8.2 KiB
XML

<Project>
<!--
Run this after GetAssemblyVersion because it happens after the Xaml compiler
and exists in both xaml and non-xaml projects. One of the (many) xaml compile
passes wipes out the additional compile includes that we add.
-->
<Target
Name="CompileProtos"
AfterTargets="GetAssemblyVersion"
Condition="'@(Proto)'!=''"
Inputs="$(protoc);
%(Proto.Identity);$(ProtocPluginBase)\plugin.py;
$(ProtocPluginBase)\templates\c#\immutable.pb.cs;"
Outputs="
%(Proto.OutDir)\%(Proto.CSName).cs;
%(Proto.OutDir)\%(Proto.FileName).immutable.pb.cs">
<MakeDir Directories="%(Proto.OutDir)" />
<Message
Importance="High"
Text="Generating Proto %(Proto.FileName)" />
<PropertyGroup>
<GenProtosCmd>$(protoc) %(Proto.FullPath)</GenProtosCmd>
<GenProtosCmd>$(GenProtosCmd) --error_format=msvs</GenProtosCmd>
<GenProtosCmd>$(GenProtosCmd) --proto_path=$(SourceRoot)</GenProtosCmd>
<GenProtosCmd>$(GenProtosCmd) --plugin=&quot;protoc-gen-spark-csharp=$(ProtocPlugin)&quot;</GenProtosCmd>
<GenProtosCmd>$(GenProtosCmd) --spark-csharp_out=lang=c#,templates=immutable.pb.cs,strip_out_path=1:%(Proto.OutDir)</GenProtosCmd>
<GenProtosCmd>$(GenProtosCmd) --csharp_out=%(Proto.OutDir)</GenProtosCmd>
</PropertyGroup>
<Exec Command="$(GenProtosCmd)" WorkingDirectory="%(Proto.RelativeDir)" />
<ItemGroup>
<Compile Include="%(Proto.OutDir)\%(Proto.CSName).cs" />
<Compile Include="%(Proto.OutDir)\%(Proto.FileName).immutable.pb.cs" />
</ItemGroup>
</Target>
<Target
Name="CopyConfigurationProfiles"
AfterTargets="Build"
Condition="'@(ConfigurationProfile)'!=''"
Inputs="%(ConfigurationProfile.Identity)"
Outputs="%(ConfigurationProfile.OutDir)%(ConfigurationProfile.Identity)">
<Copy SourceFiles="%(ConfigurationProfile.FullPath)" DestinationFolder="%(ConfigurationProfile.OutDir)" />
</Target>
<Target
Name="CopyConfigurationProfilesToPublish"
AfterTargets="Publish"
Condition="'@(ConfigurationProfile)'!=''"
Inputs="%(ConfigurationProfile.Identity)"
Outputs="%(ConfigurationProfile.PublishOutDir)%(ConfigurationProfile.Identity)">
<Copy SourceFiles="%(ConfigurationProfile.FullPath)" DestinationFolder="%(ConfigurationProfile.PublishOutDir)" />
</Target>
<!--
Run this after GetAssemblyVersion because it happens after the Xaml compiler
and exists in both xaml and non-xaml projects. One of the (many) xaml compile
passes wipes out the additional compile includes that we add.
-->
<Target
Name="CompileProtoServices"
AfterTargets="GetAssemblyVersion"
Condition="'@(ProtoService)'!=''"
Inputs="$(protoc);
%(ProtoService.Identity);$(ProtocPluginBase)\plugin.py;
$(ProtocPluginBase)\templates\c#\client.pb.cs;
$(ProtocPluginBase)\templates\c#\server.pb.cs;
$(ProtocPluginBase)\templates\c#\immutable.pb.cs;"
Outputs="
%(ProtoService.OutDir)\%(ProtoService.CSName).cs;
%(ProtoService.OutDir)\%(ProtoService.FileName).client.pb.cs;
%(ProtoService.OutDir)\%(ProtoService.FileName).server.pb.cs;
%(ProtoService.OutDir)\%(ProtoService.FileName).immutable.pb.cs">
<MakeDir Directories="%(ProtoService.OutDir)" />
<Message
Importance="High"
Text="Generating ProtoService %(ProtoService.FileName)" />
<PropertyGroup>
<GenProtosCmd>$(protoc) %(ProtoService.FullPath)</GenProtosCmd>
<GenProtosCmd>$(GenProtosCmd) --error_format=msvs</GenProtosCmd>
<GenProtosCmd>$(GenProtosCmd) --proto_path=$(SourceRoot)</GenProtosCmd>
<GenProtosCmd>$(GenProtosCmd) --plugin=&quot;protoc-gen-service=$(ProtocPlugin)&quot;</GenProtosCmd>
<GenProtosCmd>$(GenProtosCmd) --service_out=lang=c#,strip_out_path=1:%(ProtoService.OutDir)</GenProtosCmd>
<GenProtosCmd>$(GenProtosCmd) --csharp_out=%(ProtoService.OutDir)</GenProtosCmd>
</PropertyGroup>
<Exec Command="$(GenProtosCmd)" WorkingDirectory="%(ProtoService.RelativeDir)" />
<ItemGroup>
<Compile Include="%(ProtoService.OutDir)\%(ProtoService.CSName).cs" />
<Compile Include="%(ProtoService.OutDir)\%(ProtoService.FileName).client.pb.cs" />
<Compile Include="%(ProtoService.OutDir)\%(ProtoService.FileName).server.pb.cs" />
<Compile Include="%(ProtoService.OutDir)\%(ProtoService.FileName).immutable.pb.cs" />
</ItemGroup>
</Target>
<Target Name="RemoveSystemRuntimeFromRefPack"
BeforeTargets="_HandlePackageFileConflicts"
Condition="'@(Reference -> WithMetadataValue('NugetPackageId', 'System.Runtime.Experimental'))' != ''">
<ItemGroup>
<Reference Remove="@(Reference)"
Condition="$([System.String]::Copy(%(Reference.Identity)).Contains('System.Runtime.dll')) and
'%(Reference.NuGetPackageId)' == 'Microsoft.NETCore.App.Ref'" />
</ItemGroup>
</Target>
<Target
Name="GenerateScanners"
BeforeTargets="BeforeBuild"
Condition="'@(Scanner)'!=''"
Outputs="$([MSBuild]::MakeRelative($(MSBuildProjectDirectory), $(ScannerOutputPath)\%(Scanner.RelativeDir)))\%(Scanner.FileName).Scanner.g.cs">
<Message Text="Generating Scanner %(Scanner.Identity)" Importance="High" />
<ItemGroup>
<LexFile Include="%(Scanner.Identity)">
<OutputFile>$([MSBuild]::MakeRelative($(MSBuildProjectDirectory), $(ScannerOutputPath)\%(Scanner.RelativeDir)))\%(Scanner.FileName).Scanner.g.cs</OutputFile>
</LexFile>
<Compile Include="$([MSBuild]::MakeRelative($(MSBuildProjectDirectory), $(ScannerOutputPath)\%(Scanner.RelativeDir)))\%(Scanner.FileName).Scanner.g.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>%(Scanner.Identity)</DependentUpon>
</Compile>
</ItemGroup>
</Target>
<Target
Name="GenerateParsers"
BeforeTargets="BeforeBuild"
AfterTargets="GenerateScanners"
Condition="'@(Parser)'!=''"
Outputs="$([MSBuild]::MakeRelative($(MSBuildProjectDirectory), $(ParserOutputPath)\%(Parser.RelativeDir)))\%(Parser.FileName).Parser.g.cs">
<Message
Text="Generating Parser %(Parser.Identity)"
Importance="High" />
<ItemGroup>
<YaccFile Include="%(Parser.Identity)">
<OutputFile>$([MSBuild]::MakeRelative($(MSBuildProjectDirectory), $(ParserOutputPath)\%(Parser.RelativeDir)))\%(Parser.FileName).Parser.g.cs</OutputFile>
<Arguments>/gplex /nolines</Arguments>
</YaccFile>
<Compile Include="$([MSBuild]::MakeRelative($(MSBuildProjectDirectory), $(ParserOutputPath)\%(Parser.RelativeDir)))\%(Parser.FileName).Parser.g.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>%(Parser.Identity)</DependentUpon>
</Compile>
</ItemGroup>
</Target>
<Target
Name="CleanProtos"
AfterTargets="Clean">
<Delete Files="%(Proto.OutDir)\%(Proto.CSName).cs" />
<Delete Files="%(Proto.OutDir)\%(Proto.FileName).client.pb.cs" />
<Delete Files="%(Proto.OutDir)\%(Proto.FileName).server.pb.cs" />
<Delete Files="%(Proto.OutDir)\%(Proto.FileName).immutable.pb.cs" />
<Delete Files="%(ProtoService.OutDir)\%(ProtoService.CSName).cs" />
<Delete Files="%(ProtoService.OutDir)\%(ProtoService.FileName).client.pb.cs" />
<Delete Files="%(ProtoService.OutDir)\%(ProtoService.FileName).server.pb.cs" />
<Delete Files="%(ProtoService.OutDir)\%(ProtoService.FileName).immutable.pb.cs" />
</Target>
<Target
Name="CleanScanners"
AfterTargets="Clean"
Condition="'@(Scanner)'!=''">
<Delete Files="$([MSBuild]::MakeRelative(%(Scanner.RootDir)%(Scanner.Directory), $(ScannerOutputPath)))\%(Scanner.FileName).Scanner.g.cs" />
</Target>
<Target
Name="CleanParsers"
AfterTargets="Clean"
Condition="'@(Parser)'!=''">
<Delete Files="$([MSBuild]::MakeRelative(%(Parser.RootDir)%(Parser.Directory), $(ParserOutputPath)))\%(Parser.FileName).Parser.g.cs" />
</Target>
<Target
Name="CleanConfigurationProfiles"
AfterTargets="Clean"
Condition="'@(ConfigurationProfile)'!=''">
<Delete Files="%(ConfigurationProfile.OutDir)\%(ConfigurationProfile.Identity)" />
</Target>
<Target
Name="Test"
DependsOnTargets="Build"></Target>
</Project>